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);
}
}
↧