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

Getcomponent null reference exception

$
0
0
Why am I getting a null reference exception when I call the hear noise function? NullReferenceException: Object reference not set to an instance of an object this class is attached to a crate object and when it falls it calls the enemy object to come to it. public class Crate : MonoBehaviour { public AudioClip collisionNoise; EnemyCylinder EC; //turns on alien hear sound. void OnCollisionEnter(Collision other) { AudioSource.PlayClipAtPoint(collisionNoise, transform.position); //BroadcastMessage("HearNoise", this.transform.position); EC = GetComponent(); EC.HearNoise(this.transform.position); } }

Viewing all articles
Browse latest Browse all 171066

Trending Articles



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