- Home /
OnTriggerEnter() not called
I have a player (sphere) and 4 enemies (capsules). All enemies have a character controller added. They also all have a child GameObject, which has a RigidBody (no mass, no gravity) and a Box Collider attached. The Box Collider is large enough so you can see the sphere model inside of the box, even with a little space in between.
The player also has a character controller, but no RigidBody. It does have a sphere attached with a mesh collider.
All of the enemies have the IsTrigger box checked. Why don't they call the OnTriggerEnter() function? What am I missing? Note that when enemies collide, OnTriggerEnter() is called. But it doesn't work on the player.
The player should be the only one to have a character controller as enemies typically are AI, which don't need the flexible movement of a character controller. Replace with a box collider is typically simplest. For the rigidbodies, check is $$anonymous$$inematic, this enables collisions sensors, but are not directly effected by physics properties. The OnTriggerEnter() only works in script that are attached to objects with collider properties that have isTrigger enabled. So, for scripting the enemies should have the handling for trigger effects.
Answer by aldonaletto · Jan 22, 2013 at 10:54 PM
I don't know if that's the case, but a moving trigger must have a kinematic rigidbody in order to detect other colliders. There's also a problem with mesh colliders: at least one of them must be convex (have Convex set).