Hi, Im have a game object with lots of children (as a 2d person with ‘limbs’ containing rigid bodies) and an object which hits it, but i need to detect when the collision occurs.
I am using the following script:
#pragma strict
function Start (){
}
function Update (){
var other : Collision;
OnCollisionEnter(other);
}
function OnCollisionEnter(other : Collision){
if (other.gameObject.name == “character”){
Debug.Log(“Smash”);
}
}
The problem is that firstly, I get an error saying the if(other.gameObject.name == “character”) line ‘object reference not set to an instance of an object’, and also the function doesn’t work as the Debug.Log isn’t activated when the objects collide. I have tried using tags and the name of the whole character with the children inside, but the problem persists, any ideas? cheers guys