简体   繁体   English

通过对象的字符-Unity3D

[英]Characters passing through objects - Unity3D

我对Unity3d相当陌生,无法使角色停止穿过从Maya导入的墙壁和房屋,它们都具有Rigidbody,我该怎么办?

In addition to the Rigidbody component, you'll need to attach Collider components to your objects. 除了Rigidbody组件之外,您还需要将Collider组件附加到对象上。 The best collider to use varies by object shape, so for some objects you might use a Box Collider while others would warrant a Sphere or Capsule Collider. 最好使用的对撞机随对象形状的不同而不同,因此对于某些对象,您可以使用Box Collider,而另一些则需要Sphere或Capsule Collider。 When you attach a Collider component to an object, you'll see a green outline in the editor that shows you the shape of the collider as you adjust it. 将对撞机组件附加到对象时,您将在编辑器中看到绿色轮廓,该绿色轮廓向您显示对撞机的调整形状。

There is also a Mesh Collider that uses the actual geometry of the model for collisions, but this is slow and has limitations. 还有一个“网格碰撞器”(Mesh Collider),它使用模型的实际几何形状进行碰撞,但这很慢且有局限性。 ( For one, mesh colliders can only collide with other mesh colliders if their "convex" flag is set ) 例如,如果设置了“ convex”标志,则网格碰撞器只能与其他网格碰撞器碰撞

Another thing: The Rigidbody component only needs to be attached to objects that should move, such as the character. 另一件事:刚体组件仅需要附加到应移动的对象(例如角色)上。 Walls and houses generally don't need the Rigidbody component. 墙壁和房屋通常不需要刚体组件。

If your character has Rigidbody and a Collider, and the walls/houses each have a Collider, then your character shouldn't pass through them. 如果您的角色有刚体和对撞机,并且墙壁/房屋都具有对撞机,那么您的角色就不应穿过它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM