With multiple colliders under a rigid body is it possible to tell which collider made the collision on the “this”(source) body?
Let me further explain:
I have a collision between two instances of the same prefab. Here’s the prefab setup.
-
Character (GameObject)
-
rigidbody (Component?)
-
box collider (Component?)
-
Range (GameObject)
-
box collider (Component?)
So Range is a child GameObject of Character. All collider’s have isTrigger checked. I don’t want physics based reactions, I simply want colliders to manage collisions.
Anyway, a component off of Character has this collision code.
void OnTriggerEnter(Collider other) {
FieldUnit collidee = other.gameObject.GetComponent<FieldUnit>();
if (collidee.side != side) //only collide with enemies
{
Debug.log(other.gameObject.name);
}
}
Now other.gameObject.name above appears to give me the name of the gameObject that was collided into. What I need to know is which gameObject on the current/source/this instance made the collision. Was it the Character’s box collider? or the Range box collider?
Is there a way of doing this? Or is there a better way to go about this in Unity?
Thanks!