Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10551

Detect trigger with mesh collider but without convex check

I want a precise mesh collider for trigger but the problem is i can't do trigger without making the mesh collider convex. is there any way available to detect trigger without making mesh collider convex.? or can i make mesh collider precise with convex check.

Upvotes: 1

Views: 7143

Answers (2)

Dávid Florek
Dávid Florek

Reputation: 571

The triggers have to be convex. It's the PhysX limitation. The best approach would be to open the collider mesh in modeling program you use and split it into multiple meshes until all the meshes are convex.

Upvotes: 0

rutter
rutter

Reputation: 11452

Is the mesh actually convex? If you can draw a ray from every vertex to every other vertex without crossing through any faces of the mesh, then it is convex. If you cannot do that, then it is concave.

Convex mesh colliders are easy enough: enable the convex setting, and you're done.

Concave mesh colliders are a problem. It's tricky to get them to behave right, and they're not great for performance. Rather than doing that, it's almost always preferable to create a "compound collider" out of multiple concave mesh colliders (or other primitive colliders). As long as you attach a parent component (either a Rigidbody or script) to receive collision events from the children, it behaves as if it's one solid object.

Upvotes: 1

Related Questions