Mesh Collider具有应在其中放置孔并变形的壁 [英] Mesh Collider has walls where holes should be and is deformed

查看:141
本文介绍了Mesh Collider具有应在其中放置孔并变形的壁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的弯曲水管模型需要一个弯曲圆柱对撞机,以便玩家的红色立方体可以轻松通过.

I need a curve cylinder collider for my curve water pipe model so that my player red cube can pass easily through.

我尝试了网格碰撞器,它不起作用,还尝试了另一种技巧,即在搅拌器中构建2个模型,一个用于网格渲染,一个用于碰撞器.整体上每9个块中就有一个导致网格对撞机无法在整个一个对象上工作检查图1和图5:在将两个模型导出为统一后,我分别对所有9个管道应用了网格对撞机以达到完美结果为pic no:5个对撞机外观完美但无法正常工作的结果,红色方块播放器无法通过管道

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

对撞机不允许玩家如图所示进入另一侧.我需要一个用于弯管的完美对撞机,以便播放器可以轻松通过.在图一中,我显示了应用网格碰撞器结果后的情况.在图2中,我展示了我再次构建模型,但是在9个块中,因为选择了一个块,您可以看到,将网格碰撞器分别应用于所有9个块以获得良好的效果.在图5中,我显示了最终结果,它看起来不错,但是对撞机无法正常工作,它不会让我的小红盒子玩家进入管道并通过管道.在图3中,我瞄准了.在图4中,我开了枪,表明我们的球员没有参加比赛.

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.

推荐答案

之所以会出现此问题,是因为Unity将您的网格物体转换为凸形形状,从而消除了管中的孔.还将顶点数减少到255个三角形,这是凸网格的最大值.这就是为什么对撞机在第一张照片中如此变形的原因.

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.

这里有2个主要选项供您选择,因为管子本质上是非凸形的.

There are 2 main options for you here, because tubes are inherently non-convex shapes.

  1. 确保在网格对撞机上未未选中并且管上没有没有刚体.然后,多维数据集应该能够进入管中.但是,这将意味着其他MeshColliders将无法与管碰撞.如果仅将其与BoxColliders,SphereColliders或CapsuleColliders等相撞,则应该可以正常工作.

  1. 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.

将管破碎成一系列的形状,并使每个管成为单独的 MeshCollider.然后,您在这里遇到的情况应该可以正常工作.

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.

从MeshCollider文档中:

From the documentation of MeshCollider:

凸出-选中复选框以启用凸出.如果启用,则此网格碰撞器"将与其他网格碰撞器"碰撞. **凸网格碰撞器限制为255个三角形. **

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. **

...

未启用的网格碰撞器仅在没有 Rigidbody 的GameObjects上受支持 组件.

Mesh Colliders that do not have Convex enabled are only supported on GameObjects without a Rigidbody component.

这篇关于Mesh Collider具有应在其中放置孔并变形的壁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆