Mesh collider not working after rotation
I would like to create a polygon on a GameObject at runtime.
I do the following at runtime:
1. Create GameObject (GO)
2. Add polygon component to GO
3. Define points with .AddPoints --> Creates polygon on the XY plane of the GO
4. Add a mesh collider
5. Rotate the GO so the polygon is pointing up (Y world). Because I need it on the XY world plane
6. Trying to raycast on the polygon doesn't work. The meshcollider gets a hit only in the original position (GO euler angles = (0,0,0)) and not when rotated ((90,0,0)).
I tried to call the UpdateMesh(true) after step 3, but it doesn't work.
I tried to define a GO (not at runtime), adding a meshcollider and it still doesn't work. It works only with a boxcollider.
I am not sure it's a bug or I am missing something with the colliders and how the mesh is defined in a polygon.
Is this an expected behaviour?
Thanks
there's nothing special about what happens when rotating a mesh - it sounds like you might simply always be getting the raycast hit location in local space? in which case you'll have to transform it back
it shouldn't be a problem if you're using Physics.Raycast, but you might have to transform the coordinate with the way you're doing it now?
one way to check would be to test with another mesh collider using a different mesh