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 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值