# How to get “this” object collider name when OnTriggerEnter is fired?

I have a "car" object with 2 colliders attached, a base and a top collider. Then I have a script attached to my car. I'm using OnTriggerEnter event to detect collisions with an invisible "Checkpoint". The problem is that OnTriggerEnter is called twice, I suppose because it is called either from the base collider and top collider. I want to check my object collider's name. OnTriggerEnter expose me with "other" collider; however, how can I test my collider's name?

• I have been searching for the answer to this exact question. This should be extremely basic functionality of the OnTrigger event... – Shadoninja Dec 30 '17 at 17:46

## 1 Answer

You don't need to check the current object tag, since the OnCollisionEvent would only fire on the object you attached your monobehaviour script to.

Either your GameObject is bouncing and is registering two collision enter events in quick succession -- or it is colliding with at least 2 other colliders.

Tag your collider types so you can easily check to see what you are colliding with. Then you can add a debug statement in your OnCollisionEnter to see what is going on:

Debug.Log("Collided With: " + collider.gameObject.tag);

• I need to check, because my script is 'attached' to main game object, but the two collider are child of an empty child gameobject .. About collider.gameObject.tag Unity tell me it is obsolete and won't compile :( – stighy Jun 4 '16 at 12:19
• As the asker describes, the object has a sub object that has a second collider. The second collider is firing the second OnCollisionEvent. I have just confirmed that this setup will fire two events; not just one. – Gnemlock Dec 4 '16 at 2:48