问题
I need a curve cylinder collider for my curve water pipe model so that my player red cube can pass easily through.
I tried mesh collider it doesn't works and also tried another trick where I build 2 models in blender one for mesh render, one for collider. one as a whole one in 9 chunks cause mesh collider was not working on whole one object check pic no:1 and check pic no:5 where after exporting both models to unity I applied mesh collider on all 9 chunks of pipe separately to get perfect results in pic no:5 results of collider look's perfect but not working perfect the red box Player can't pass through the pipe
Collider doesn't let the player get inside and out from another side as shown in pictures. I need a perfect collider for my curve pipe so that my player can easily pass through. In pic one I showed that after applying mesh collider results. In pic two I showed I build my model again but in 9 chunks as one chunk is selected you can see, To apply mesh collider on all 9 chunks separately to get good results. In pic 5 I showed final result it looks good but not working the collider is not letting my small red box player inside the pipe and pass through it. In pic 3 I am aiming. In pic 4 I fire and showed that our player does'nt get in the pipe.
回答1:
This problem is caused because Unity is turning your Mesh into a convex shape, which removes holes from the tube. It will also reduces the vertex count down to 255 triangles, the maximum for a convex mesh. That is why the collider gets so deformed in the first picture.
There are 2 main options for you here, because tubes are inherently non-convex shapes.
Make sure
Convex
is not checked on the mesh collider and that there is no rigidbody on the tube. Then, the cubes should be able to enter the tube. However, this will mean that other MeshColliders will not be able to collide with the tube. If you're only colliding it with BoxColliders, SphereColliders, or CapsuleColliders and so on, this should work fine.Break up the tubes into a series of convex shapes, and make each one a separate MeshCollider. Then the situation you have here should work fine.
From the documentation of MeshCollider:
Convex - Tick the checkbox to enable Convex. If enabled, this Mesh Collider collides with other Mesh Colliders. **Convex Mesh Colliders are limited to 255 triangles. **
...
Mesh Colliders that do not have Convex enabled are only supported on GameObjects without a Rigidbody component.
来源:https://stackoverflow.com/questions/56279930/mesh-collider-has-walls-where-holes-should-be-and-is-deformed