- Home /
Duplicate Question - http://answers.unity3d.com/questions/topics/nullreferenceexception.html
Null reference error after detecting collision
I know this particular Nullreference exception question has been asked many many times. so sorry for that.
My problem is after detecting collision even i can use one method from a class i can not use a function from another class both classes are very similar to one another so i dont get why i get "Object reference not set to an instance of an object"
project is working except for that part which is making me go crazy. and i can not create the win conditions.
here is the project files its just 120KB so please let me know what is the mistake i am doing.
https://drive.google.com/file/d/0B_y3N0jciYFSWHBFbG1qZzNLazA/edit?usp=sharing
Thanks in advance.
Error Log:
NullReferenceException: Object reference not set to an instance of an object Goal.GetPoint () (at Assets/SCRIPTS/Goal.cs:11) UnityEngine.Component:SendMessage(String, SendMessageOptions) BALL_MOVEMENT_SCRIPT:OnTriggerEnter(Collider) (at Assets/SCRIPTS/BALL_MOVEMENT_SCRIPT.cs:50)
first of all, this is where people post sections of code with problems, etc. people helping aren't likely to go somewhere to download a whole project (no matter how small).
that said, check that you have added references to all of your other objects that need to communicate with one another.
for example, your Scorekeeper
needs to know where the player score display components are.
your goal objects don't have a reference set to the '`Scorekeeper`' either...
if you have a single score manager (named Scorekeeper
in your case) it's a good idea to use the Awake()/Start()
functions to get a reference to it ins$$anonymous$$d of remember to set it in the Inspector (which you forgot!). if you've only got 2 of them it's not a big deal, but if it were something you had a lot more of, then it's more things to fix/change/etc.
one thing you'll need to do when you fix those things is remember to check the direction for the ball when you restart it... make sure it's headed back to the other player...
Follow this Question
Related Questions
Attached scripts as List? 1 Answer
NullReferenceException script problem? 0 Answers
I'm having more problems accessing a variable from another script in c# 2 Answers
how do I find what causes "NullReferenceException" 2 Answers
NullReferenceException 1 Answer