I am trying to use this code:
function OnTriggerEnter(other : Collider){
if (other.gameObject.CompareTag (“Enemycar”)) {
Destroy(other.gameObject);
}
}
The gameobject with the “Enemycar” tag is a vehicle with a compound collider (several box colliders for the body) and raycast colliders for the wheels. The case is the code is not working and when enter the trigger the car object is not destroyed.
What is wrong?
If u simplify the gameObjects with one total rigidbody and meshcollider, does it work then?
I’m pretty new myself and i had a similair problem. Then i put a rigidbody and mesh on the parent and it worked perfectly.
Regards,
MisterEd.
Use other.transform.root.CompareTag instead (root is the highest parent of the current transform tree).
Use other.transform.root.CompareTag instead (root is the highest parent of the current transform tree)
It doesn´t work.
Make sure that the method/function OnTriggerEnter is called at all first.
My suggestion is to put a Debug.Log("ontriggerenter hit ") right after the function declaration.
if it is not being called at all, make sure you have istrigger, or whatever the property is called, in the inspector.
if you are sure that ontriggerenter is being called, next step would be to put a similar debug call with something like
debug.log(other.root.name) and make sure you get what you expect and deserve 
HTH