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

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -