http://docs.unity3d.com/Manual/CollidersOverview.html
因為官網沒有圖,這次就不貼介紹了,畢竟都英文的
所以就由我來直接解釋吧
Collider就是碰撞框
物件附上碰撞框屬性之後就會賦予它偵測與其他物件碰撞的範圍和能力
有了碰撞框才能做出例如地面、牆壁、砲彈等等,能阻礙或擊中物體的效果
而碰撞框有好幾種形狀
主要有長方形、球形、膠囊型、圓柱形,比較異類的有地形碰撞框、Wheel Collider 、Mesh Collider(不知怎翻譯才好),一個物件可以利用多個碰撞框組成複雜的碰撞框,這邊想知道詳情請點上方官方教學連結
而碰撞框自身又有兩種類型
Trigger(觸發器)和非Trigger
在設計上觸發器類型的碰撞框通常用來做事件出發的應用(簡單來說就是用來偵測玩家或物件進入指定區域)
而非觸發器類型通常就是配合Rigidbody去實做物理現象的碰撞效果(兩顆球相撞)
觸發器碰撞過程會觸發
OnTriggerEnter | OnTriggerEnter is called when the Collider other enters the trigger. |
OnTriggerExit | OnTriggerExit is called when the Collider other has stopped touching the trigger. |
OnTriggerStay | OnTriggerStay is called almost all the frames for every Collider other that is touching the trigger. |
OnCollisionEnter | OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider. |
OnCollisionExit | OnCollisionExit is called when this collider/rigidbody has stopped touching another rigidbody/collider. |
OnCollisionStay | OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider. |
以下是官方的碰撞發生表,不過這等到實際開始用Collider,已經有些實際上試用後的理解或困惑,再來看會比較看得懂^ ^|||
Collision detection occurs and messages are sent upon collision | ||||||
---|---|---|---|---|---|---|
Static Collider | Rigidbody Collider | Kinematic Rigidbody Collider | Static Trigger Collider | Rigidbody Trigger Collider | Kinematic Rigidbody Trigger Collider | |
Static Collider | Y | |||||
Rigidbody Collider | Y | Y | Y | |||
Kinematic Rigidbody Collider | Y | |||||
Static Trigger Collider | ||||||
Rigidbody Trigger Collider | ||||||
Kinematic Rigidbody Trigger Collider |
Trigger messages are sent upon collision | ||||||
---|---|---|---|---|---|---|
Static Collider | Rigidbody Collider | Kinematic Rigidbody Collider | Static Trigger Collider | Rigidbody Trigger Collider | Kinematic Rigidbody Trigger Collider | |
Static Collider | Y | Y | ||||
Rigidbody Collider | Y | Y | Y | |||
Kinematic Rigidbody Collider | Y | Y | Y | |||
Static Trigger Collider | Y | Y | Y | Y | ||
Rigidbody Trigger Collider | Y | Y | Y | Y | Y | Y |
Kinematic Rigidbody Trigger Collider | Y | Y | Y | Y | Y | Y |
沒有留言:
張貼留言