In my game, when a character jumps on a certain object, it is supposed to do something. As the code follows, when the character jumps on a object, the character takes the parent’s name. Depending on the name, it will do something, but at the if… then… statement in the code, there is a NullReferenceExeption when the character jumps on anything.
Heres the code:
function OnControllerColliderHit (hit : ControllerColliderHit) {
var name = hit.gameObject.transform.parent.name;
if (name == "Thing") {
Debug.Log("Yay!");
}
}