Unity3D的碰撞檢測遇到的有趣BUG

Assume that A and B are both given the Box Collider. If we use the function bound.Intersect() to detect the collide between A and B, there seems a way to make this kind of detection effectiveness and the method is:

1. Rotate A and B

2. use the function bound.Intersect() to detect the collision event.

 

then we can see we fail to detect this collision event.

If we skip the first step, we can dectect the collision well.

 

假如A與B已經被賦值好了一個Box Collider用於檢測碰撞,碰撞檢測函數用的是Bound.Intersect(),有一種方法似乎可以讓這個函數失效

1. 旋轉A與B

2. 利用Bound.Intersect()檢測碰撞

我們可以看到AB的碰撞無法檢測,而跳過第一個步驟就可以正常檢測。

 

不知道是什麼原因導致的……

 

Finally, the bug is debugged. It is just because whether you have understand the word 'intersect' or not. 'Iintersect' mean A's origion  is in B or B' origion is in A, then the U3D wont think A and B is collide under the function bound.Intersect() if the origions of both A and B are not in the other box collider.

最終,我終於通過Intersect這個詞彙的本意得知了BUG的緣由,Intersect函數並不是檢測包圍盒是否有交集,而是檢測A或者B物體的原點是不是在另一個物體的包圍盒中,雖然感覺很不合理,但是實驗結果是這樣的,我覺得這也是U3D引擎的BUG吧,所以 當我旋轉 A  和 B物體的時候,他們的原點脫離了另一個物體的包圍盒,雖然看起來他們的包圍盒還是有交集,但是由於原點不在另一方的包圍盒中,碰撞檢測的返回值仍然是false 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章