Getting a NullReference Exception when I press play

When I add the Ball Hander Script I get a Null Reference Exception, Object refence not set to and instance of an object. And it points to line 11 in my BallHandler.cs

BallHandler.cs

Which I cant see anything wrong with. And the BallHandler empty object has the script attached to it as well.

I have redone the script a couple of times and each the same issue.

Many thanks

Hi Paul,

For some reason this question did not appear in the daily search for the Q&A questions and not sure why so i do apologise that you havent got a reply to this in a more timely manner.

I wonder if you found a solution to this and have moved on from this lecture?
Your logic is different to the course (Lecture may have been updated) but checking the lines of code you have posted the logic would work regardless.

Hope you are enjoying the course.

Hi Marc no could not get it to run at all, wiped the project and will try again. Will re post if I hit the same issue.

1 Like

I also have this issue, and I simply downloaded the finished script from Gitlab and hooked it all up in the editor. I even get the same error if I download the completed project. I am on 2021.1.12f1, if that makes a difference. Futhermore, I notice that intellisense does not autocomplete the Touchscreen class. I’m going to test it on 2020 LTS tonight.

Update:
I can confirm that it works on 2020 LTS. So, there must be a bug in newer versions of Unity.

1 Like

Thanks Verkland,

It must be something to do with the packages and the version i think as i am using 2020.3 and did not experience this error either.
I think for now its recommend to stick with the version in the course (Or the 2020 variant) and everything should work fine.

Thanks for posting the solution :slight_smile:

Edit :- I’ve passed this along to Nathan with some other 2021 issues that happens.
The auto complete is a bit odd but that might be to do with the VS code plugin not playing nice with 2021, reinstalling this often solves the issue.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms