I’ve stumbled upon this thread, which says, that it’s not possible to access a child’s rigidbody.
http://forum.unity3d.com/threads/36462-onCollisionEnter-does-not-work-on-a-child-colider
Now, i have the opposite situation, i’ve got my player as parent, with the graphics and the character controller as child.
The collision event does work, thus it seems i can’t access the parent’s rigidbody. It returns null.
Is this the intented behaviour?
I’ve tried to access it via
void OnTriggerEnter(Collider obj) {
if (obj.tag == "Player"){
obj.transform.gameObject.SendMessage("apply_damage", damage, SendMessageOptions.DontRequireReceiver);
player = obj.transform.parent.gameObject;
player.rigidbody.AddExplosionForce(pushback*2, obj.transform.position,2,3, ForceMode.Impulse);
Destroy(gameObject);
}
}