Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Null RefferenceException Error when accessing bool from another script

$
0
0
Really don't need to explain much but basically one script needs to know when the game is over from another script. I have checked all over and I don't believe I am doing anything wrong but I am still getting an error (null reference exception.) Here is my code: public bool GameOver; // Use this for initialization void Start () { } // Update is called once per frame void Update () { Movement movementScript = GetComponent(); if(movementScript.GameOver == false) { GameOver = false; } if(movementScript.GameOver == true) { GameOver = true; } Debug.Log(GameOver); if(EscClicked == false && GameOver == false) { Didn't copy the entire script on purpose ;) And here is the other script: void OnTriggerEnter(Collider other) { GameOver = true; Camera.mainCamera.transform.position = FinishedCameraPosition; Camera.mainCamera.transform.rotation = FinishedCameraRotaition; } More than enough of this script ;)

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>