Do Mesh Colliders Understand Volume?

Hi,

I created a primitive capsule to use as a trigger for a script.

  • isTrigger = true
  • No rigid body
  • Doesn’t move

My enemies:

  • Have collider, not set as trigger
  • Have a rigidbody - isKinematic = true

Everything worked as expected.

I then decided I would like to try a mesh-collider so I have more control over the shape/size of my trigger.

  • Added mesh-collider (replaced capsule collider by GUI)
  • Set as trigger

Now when my enemies move in to the colider, OnEnter is called as expected, but OnExit is called as the enemy moves inside the collider. As soon as the enemy no longer has direct contact with the mesh, it is considered OnExit, even though it is still in the volume of the mesh.

OnStay works only while the enemy collider is in contact with the mesh as well. once inside or outside, it does OnExit.

is this normal?

I tried every combination of triggers and rigidbodies but the trigger events are still acting differently than with a primitive collider.

Cheers,

A default mesh collider detects contact with the outer surface only, so the behaviour you are seeing is correct. However, if you switch on the collider’s Convex property, it will be aware of the volume of the mesh and detect objects entering and leaving that volume. Note that a convex mesh collider is limited to 255 triangles and is reduced to the convex hull of the mesh (ie, it’s as if the collider is a tight rubber sheet stretched around the original object).

I thought you might say that. I wanted to try it but all the built-in primitives have too much geo to try it and I’m not importing from Maya yet (still in early dev tests and I haven’t installed Maya on my new computer yet)

I’ll push a team-member to hurry up with import tests now :wink:

For use as an OnEnter- and OnExit-only trigger (no OnStay), do you think mesh-colliders are much more expensive than a capsule collider?

Thanks!