Hi.
I have two GameObjects
Body1 and Body2, Both have separate BoxCollider
. i want to identify which GameObject
(Body1 or Body2) have hit the other.
@JaZZi
I’m not quite sure what you mean, but maybe this will help
You can give your different objects different tags, and then check if the tags on the collided object is equal to the objects tag. To give an object a tag, you need to create it under edit/project settings/tags and layers, and then apply the tag under the inspector.
void OnCollisionEnter(Collision other) {
if(other.transform.tag == "Body2")
//then do something
}
You can also choose which objects that can collide with eachother under edit/project settings/physics and then change the “layer collision matrix”. To insert objects into the matrix, you need to create a new layer, under edit/project settings/tags and layers, and then apply the new layer to the object under the inspector.