Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Object reference not set to an instance of an object

$
0
0
Im trying to make the "Game Over" part of my game and i ran into this error, and i have no idea how to fix this. Can someone help me out? Here's the code public GameObject Wreck; public GameObject ISLWreck; private game_controller gamecontroller; void Start() { GameObject gamecontrollerobj = GameObject.FindWithTag("GameController"); if (gamecontrollerobj != null) { gamecontroller = gamecontrollerobj.GetComponent(); } } void OnTriggerEnter(Collider other) { if (other.tag == "Boundary") { return; } if (other.tag == "Background") { return; } if (other.tag == "Hazard") { Destroy(other.gameObject); Destroy(gameObject); Instantiate(ISLWreck, transform.position, transform.rotation); gamecontroller.Gameover(); } else { Destroy(other.gameObject); Destroy(gameObject); Instantiate(Wreck, transform.position, new Quaternion(-90, 45, 45, 0)); gamecontroller.Gameover(); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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