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
Post a Comment