- Home /
Strange NullReferenceException
I have been working a my game for a while and everything has been working fine until today. My win script suddenly stopped working without any change from me. I'm really pulling my hair out on this one. The object goal is in the level and it is referenced in the script.
// Win Condition
if (Vector3.Distance(Body.transform.position, Goal.transform.position) < .5) {
// If the distance between Body and Goal is Less Than n, play the Goal sound and set the GoalFlag to true
// adjust this number to match your Body and Goal sizes, and world scale
if (WinFlag == false) {
OverlayFlag = false; //We set this to false so that the Overlay and Win text don't collide. Change if needed.
audio.clip = WinClip; // set our Audio Source to (cue) this clip
audio.Play(); // command the audio source to Play
HubScript.CFlag = true;
Application.LoadLevel("Hub");
}
}
On what line is the error?
Have you added:
Debug.Log(Body);
Debug.Log(Goal);
yes and its what would be line 2. I did not post the entire script because the error is from an independent section of my main script. on the real script I believe it is line 248.
Answer by wingren013 · Apr 20, 2013 at 09:47 PM
I just solved it. I had a curly brace above //Win Condition that closed off function update
Your answer
Follow this Question
Related Questions
Keep adding targets to a list 2 Answers
Rotating a Vector3 in Instantiation 1 Answer
how can i move another gameobject from a single script? 1 Answer
Convert Transform to Gameobject 1 Answer