標籤:
兩個Gameobject 放置在空中, 一個是Cube,一個是茄子模型
Cube的Collider 是Box Collider , 茄汁的Collider 是mesh collider, 他們都添加了剛體(RigidBody)組件, 勾選了重力Gravity
但是, 啟動並執行結果是:
正方塊Cube下落, 掉到地面上停了下來
茄子下落,沒有停下來, 穿透了地面,一直往下掉。
百事不得其解。。。
終於還是在官方文檔中看到這段話:
There are some limitations when using the Mesh Collider. Usually, two Mesh Colliders cannot collide with each other. All Mesh Colliders can collide with any primitive Collider. If your mesh is marked as Convex, then it can collide with other Mesh Colliders.
使用網格碰撞器有一些限制條件。通常,兩個網格碰撞器之間不會發生碰撞。所有的網格碰撞器可以和任何原型碰撞器碰撞。如果網格標記為凸起的(Convex),那麼就可以和其他網格碰撞器碰撞。
試了一下, 把茄子Mesh Collider的Convex 勾上,
OK了, 停下來了!
還有一下注意事項:
http://www.ceeger.com/Components/class-MeshCollider.html
Hints 提示
- Mesh Colliders cannot collide with each other unless they are marked as Convex. Therefore, they are most useful for background objects like environment geometry.
除非被標記為凸起的(Convex),否則網格碰撞器間不會發生碰撞。因此,它們最常被用於背景對象比如環境布景。
- Convex Mesh Colliders must be fewer than 255 triangles.
凸起的網格碰撞器含有的三角形面不能多於255個。
- Primitive Colliders are less costly for objects under physics control.
原型控制器對於對象的物理控制更加節省資源。
- When you attach a Mesh Collider to a GameObject, its Mesh property will default to the mesh being rendered. You can change that by assigning a different Mesh.
當為遊戲對象附加了網格碰撞器,其網格屬性將被定義為用於渲染的網格,可以通過指派其他網格來改變。
- To add multiple Colliders for an object, create child GameObjects and attach a Collider to each one. This allows each Collider to be manipulated independently.
要給一個對象添加多個碰撞器,應該建立子物件並給每個子物件添加一個碰撞器。這使每個碰撞器可以被單獨操作。
- You can look at the gizmos in the Scene View to see how the Collider is being calculated on your object.
可以通過情境視圖(Scene View )中的線框(gizmos)來查看碰撞器在你的對象上的預期效果。
- Colliders do their best to match the scale of an object. If you have a non-uniform scale (a scale which is different in each direction), only the Mesh Collider can match completely.
碰撞器盡量匹配對象的比例。如果有一組不規則伸縮(每一維度上的比例都不相同),只能使用網格碰撞器才能完全符合。
- If you are moving an object through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.
如果你想接收通過Transform組件移動的對象的碰撞/觸發資訊,你必須給移動對象附件剛體。
為什麼帶網格(mesh)的模型添加了剛體Rigidbody和MeshCollider,還是會從地板穿過去?