- Home /
Unity 5.0 and alternative for triggering complex meshes.
Now, when physX 3.3 is up, non-convex mesh cannot be a trigger. It gives me a headache, because half of my game was based on large mesh surface, that was a trigger. Convex mesh cannot have more triangles than 255. I tried to split my mesh to smaller parts (that already have only 255 triangles), but even then, pressing "convex" tick is just breaking my splitted mesh. I have a almost flat surface and i don't think, that
Is there now possibility to create large, static mesh, that will act like trigger? I need to know if any scene object touch my surface (like OnTriggerEnter) and objects have to be able to pass through surface (like after pressed isTrigger in collider component!). I cannot use raycasts, because objects, that can touch surface can be hundreds. Building collider from primitives also cannot be used, because my surface is generated procedurally. It can change shapes every game.
Answer by Polak149 · Mar 18, 2015 at 05:50 AM
Recently I have found different solution, that is best for flat surface. The idea is to close our complex mesh in primitive collider and try two Collider.Raycast on every object that had trigged it. We can shot first Collider.Raycast from our incoming object collider to our complex mesh. It gives as point from we can shot another raycast and gives as position where object would hit surface (at moment!). When we shot second ray to our incoming object, distance of that second ray is value between object and our trigger (mesh collider). If second Raycast return false (what basically means that distance is <=0) it had to be a touch event.
NOTE: Better our primitive fits the complex mesh, better performance we get, since less rays have to be cast.
Answer by WillNode · Mar 09, 2015 at 12:14 PM
I found a workaround about this problem :
void OnCollisionEnter (Collision other)
{
GetComponent<MeshCollider>().enabled = false;
//Do Trigger Enter Stuff
}
it's not always the best, since the objects will loses their velocities at first hit, but based on your usage, it's maybe useful.
Also note you need to Re-Enable the Mesh Collider back when the player is spawned back.
I can't do it. $$anonymous$$y surface should handle hundrets of objects. I can't endable and disable collider whole time. But i have come up with solution!
you have your own solution? can you tell me please? since i have a same problem and so far this is my best solution.
I have posted my answer and taged it as "good solutuin" :)
Your answer
Follow this Question
Related Questions
Moving Trigger not detecting stationary MeshCollider 0 Answers
How to refresh rigidbody colliders modified at runtime 0 Answers
Is there a way to determine if an object is within a trigger, from objects perspective? 2 Answers
Version 3.2 gives no OnTriggerExit when collider is parented 12 Answers
Collider IsTrigger won't work correctly with close second Collider 0 Answers