OnTriggerEnter () not called

I have a player (sphere) and 4 enemies (capsules). All enemies added a personal controller. They also have a GameObject child that has a RigidBody (no mass, no gravity) and a Box Collider. The Box collider is large enough for you to see the sphere model inside the box, even with a small gap between them.

The player also has a character controller, but no RigidBody. It has a sphere attached to a collide.

All enemies have an IsTrigger flag. Why don't they call the OnTriggerEnter () function? Note that when enemies collide, OnTriggerEnter () is called. But the player doesn't work.

+3


source to share


1 answer


Is the sphere a child of the GameObject for the player, or is it the GameObject itself? You can check where the script is located. If the script is attached to a player, but the collider is on a child GameObject, it doesn't quite work. Collider and script must be in the same GameObject.



+4


source







All Articles