- Home /
mesh trigger only triggers on intersection with mesh unless convex
What's the purpose behind this? When you mark a collider to behave as a trigger, it's no longer used in the physics system, so why is it that unity's triggering will only happen if you're intersecting the mesh? If you set the mesh trigger as convex, it works great- but then you lose tons of precision..
Am I missing something here? What do you do when you want an "L" shaped trigger, for example? Unity only allows you to add a single box collider to a game object.. are imprecise triggers the only way to go about it? That just seems... stupid. Assembling compound colliders in child objects and using them as triggers is a waste of time, since you'd also have to write a script that catches the trigger events on those game objects and reports back to the parent script.
Any ideas?
What do you mean by "intersection"? Surely triggers should be expected to fire when something intersects with them (in the sense that their solid forms overlap). You seem to be meaning something else.
nope, it's static.
also @Warwick: I mean, when an actor/object/whatever is physically intersecting the mesh trigger's polygons. Essentially what happens is, you can run a character controller into a mesh trigger that is not set to convex- and the moment it intersects it triggers OnEnter, and the moment you finish walking through the polygon 'barrier' that makes up the trigger, it triggers OnExit- even though the correct behavior would be for OnStay to fire.
Hope that makes more sense.. I know it sounds weird- I've never run into this before as I've usually been able to get away with primitive triggers until now.
Ah, you mean "intersects with the surface". Sounds like a bug to me, I've certainly never seen that documented anywhere. You're certain your Normals are pointing the right way, I assume?
Please don't invent new tags unless really necessary =/ 'imprecise' (is a special case of) -> 'precision'; 'mesh trigger' (does not exist as such, but) -> 'meshcollider', 'trigger'. (if you don't use space or uppercase while typing tags, you should get a dropdown-list of already existing tags as soon as you type at least two letters) Thanks :) Greetz, $$anonymous$$y.
Answer by jonas-echterhoff · Sep 07, 2011 at 07:37 AM
I think this limitation makes sense from an architecture point of view, since calculating if a point is inside a concave mesh is very heavy computationally. For PhysX most common use of MeshColliders (handling collisions), only detecting collisions on the surface is sufficient. Anyways, as this is most likely a limitation in NVidia PhysX, you probably cannot get around it other then by approximating your shape with compound colliders.
A $$anonymous$$esh actually doesn't represent a volume. It's just a collection of faces. A $$anonymous$$esh doesn't need to be closed, therefore there's not really an inside or outside. The collision is checked with each face / triangle. That's why they are very heavy and why $$anonymous$$eshcollider<-->$$anonymous$$eshCollider collisions are not possible. A convex $$anonymous$$eshCollider actually does represent a volume since it is forced to be closed.
+1
Answer by UGTools · Oct 18, 2012 at 12:06 PM
Convex mesh collisions are, even if more expensive than primitive collisions, quite straightforward and simple to compute. Current physics engines don't support concave dynamic objects mostly due to the fact that they are so expensive to solve. This will change in the future (nvidia already has shown realtime fracturing and concave collisions) but right now it's the only way to go. Unity uses PhysX, which is no different regarding this limitations.
The way to go around this is to use compound colliders, which you've already mentioned. But you can use triggers and they will report to the parent object automatically, so even if you use 20 primitive colliders as children you still use the same trigger event on the parent.
We've developed a Unity3D component that automatically computes a compound collider for any given object. It supports trigger events, so even if there are many colliders the event still can be processed at the parent level through the OnTriggerXXX callbacks.
Here's the component: Asset store link
Here's a demonstration video: Youtube
And here's a screenshots comparing the standard convex collider with our concave collider:
Answer by diekeure · Sep 05, 2013 at 07:06 PM
I've created a small solution to this problem: a script together with an editor script that allows you to define a polygon together with a certain height. These polygons can be concave and work the same as normal physics triggers.
http://grrava.blogspot.be/2013/07/area-concave-triggers.html
Your answer

Follow this Question
Related Questions
Create hollow sphere with objects bouncing around inside 2 Answers
Strange Convex Mesh Collider Behavior 0 Answers
Why does my trigger-collider receive Enter but not Stay or Exit? 1 Answer
Problem with mesh collider 2 Answers
Convex NonTrigger Mesh Collider + Rigidbody = weird transform position 0 Answers