I have two different objects I would like to check when A and B gameObjects are collided ?
Hi all,
How can I get solve the next problem ? :)
I have two different objects for example "Object A" and "Object B" and I have another gameObject which ones take a Script (calls: GameEngineHandler). So I would like to check when "A" and "B" gameObjects are collided, how can I get this information from another gameObject which keep the script ?? :)
Thank for the help in advance!
Here is a code snipp:
public void OnTriggerEnter(Collider col) {
if (player.GetComponent<Collider>() == colliderbox.GetComponent<Collider>()){
Debug.Log("Player and the box are collided !");
}
}
Answer by tanoshimi · Jan 13, 2017 at 02:29 PM
Object C cannot tell whether Object A and Object B collided. Collision messages are sent only to the colliders/rigidbodies involved in the collision itself.
If you want to create a collision manager you can do so, but it will need to be updated by messages sent from the OnCollisionEnter callbacks of the colliding objects themselves.