Trigger Collision Detection

Hey guys, im reading this book that has an example that says just to establish this function without even its use in the Update() or Start():

void OnTriggerEnter(Collider col){
if(col.gameObject.tag == “Player”){
transform.FindChild(“door”).SendMessage(“DoorCheck”);
}
}

The door child of the outPost Gameobject is just a door with 3 animations (idle, open, close) and the DoorCheck is the function in the door script that activates the sounds and the animations of the door.

The script i wrote above is attached on the outPost, and the character has no other scripts on it exept the prefab scripts.

The problem is that nothing happents. What can i do?

in the future, try to remember to format your code block by selecting all the code, and hitting the “101010” button… I’d fix it for you but I’m afraid to break your link…

as for your question, you will need to make sure your player is tagged as “Player” (note that this is looking at the TAG, not the name of the object), and it sounds like you have childed the door to outPost… that needs to be named door… the outPost object also needs a collider attached (and the player too, or a character controller), and the collider must be set to “is trigger”. One of the objects will also need a rigidbody (probably the outpost if you are using a character controller), just set that to “is kinimatic”… still with me?

@alucardj has some good links (in the comment above), but missing one crucial one:

http://docs.unity3d.com/Documentation/Components/class-BoxCollider.html

the collision action matrix at the bottom of the page will help explain what combinations of objects can and cannot send trigger signals… I’ve only noticed one slight discrepancy myself, as I’ve described here:

http://answers.unity3d.com/questions/292387/kinematic-trigger-with-static-collider-no-trigger.html

otherwise the collision matrix is very useful to understand why triggers often don’t work!

(…ZOOP!)