c# - Null Reference Exception on Unity's GetComponent method -


i have ontriggerenter method deal damage player when collides other objects

void ontriggerenter (collider other){      if (other.tag != gameobject.tag) {          getcomponent<health>().lowerhealth(other.getcomponent<damage>().getdamage(0));      }  } 

however,

other.getcomponent<damage>().getdamage(0)); 

line giving me null reference exception.

what correct way of doing this?

edit: have made instances of damage , have made sure components there , isnt null. error still exsist.


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -