OnTriggerEnter called when exiting collider ?!

Hi,

We are currently developing a Unity Webplayer Ski game, and in order to prevent the player from leaving the track, we have surrounded it with “invisible walls”: Mesh Colliders with the IsTrigger property set.

The player contains a Capsule Collider with the IsTrigger property set, and a Rigibody with the IsKinematic property set.

Most of the time, it works just fine, but sometimes, the player enters the collider and no OnTriggerEnter or OnTriggerStay events are called. Instead, a OnTriggerEnter event is called when the player exists the Mesh Collider.

Is this a known issue? Has anybody else encountered it?

Or is my “invisible wall” mesh too complex? In terms of number of vertices? In terms of concavity?

Could anybody recommend a solution? Should I try to make the mesh less detailed? Should I split it in multiple convex meshes? I’m afraid that having too many Colliders might have an impact on the physics engine…

Thanks in advance,
Alex

I think there’s a limit as to how complex a mesh collider can be. Most of the time you’d want to keep the collider as simple as possible. One thing you would want to change though would be the trigger part, leave the is trigger part off; you don’t want it to be a trigger. If it is a trigger then the player can go through it.
I’m assuming you just want the player to not be able to go beyond the walls, it’d be a different situation if you want the player to disappear and reappear in a different spot

Hi, and thanks for your reply.

I’m quite certain that it is a Tigger I want, as our game does not use the physics engine: When the player hits the invisible wall, we just play a “falling character” animation, and make it respawn on the track.

As to the complexity of the meshes, we’ll try to make them simpler, and see how it goes…