The question is answered, right answer was accepted
unity 5 physics.raycast ignores mesh collider
Hi!
I have a custom mesh with attached mesh collider. It is concave by it's nature (planet) and cannot be made convex. Also it is quite tricky to make it from multiple box colliders because of complexity.
I discovered that my raycasts with Physics.Raycast don't hit this mesh/collider while other rigidbodies interact with it as usual.
Please advice what can I do to make Raycast working with mesh presicion on this collider.
Thank you in advance.
AlwaysSunny, thank you very much for clarification. The issue was in my mesh. I just did not think that it can be broken. After changing mesh to similar test mesh - collider worked like a charm.
Update: it seems that collider did not work because initial mesh size was too small. I had to scale it in 3d editor and apply that scale forever (reset xform) to make it working.
lordlycastle, sorry but i don't see an option to close the question. $$anonymous$$oderator, could you please close the question with AlwaysSunny's comment as correct answer?
Answer by AlwaysSunny · Apr 04, 2015 at 10:33 PM
Possibly the normals of the collider are inverted? Not really sure what else might cause this, though I'd think collision wouldn't work right in that case either. You sure your raycast includes the correct layer? I guess it's possible that the mesh violates some rule(s) about mesh colliders; check the documentation.
A single mesh representing a roughly spherical planet is convex, not concave. If you have things like caves or geological formations with "holes through mountains" or something, I'm not sure what to call it...
In most situations, you'll want to simplify your mesh colliders as much as possible. Stability and performance can often be improved by splitting complex mesh colliders into convex chunks.