Collider2D碰撞检测异常-Rotating sprite does not rotate collider[Unity]
来源:互联网 发布:java编程规范第四版 编辑:程序博客网 时间:2024/06/09 17:32
问题描述:在Scene中明显看到碰撞体(绿框)有重叠,但是就是不触发碰撞事件。在移动物体时,发现当碰撞体未重叠的时候,反而会触发碰撞事件。经过排查,发现碰撞体所在的GameObject有设置水平反转(Y轴旋转180度)。
原因:对GameObjec的Y轴进行旋转之后,碰撞体还是保持未旋转之前的属性(虽然Scene中绿框显示有旋转,这里只是错觉)加上Anchor不在中心点,所以会导致物体和碰撞体位置不重合,才有了上面奇怪的现象。
解决方案:取消Y轴180度的旋转,将Scale设置为负,来达到反转的效果。
More:
Rotating 2D colliders in the X/Y axes is not supported. By this I mean that all 2D colliders ignore transform X/Y rotation and only use Z. This is especially important when you consider that we're limited in what deformation we can achieve via Box2D for some collider types such as the Circle collider. Allowing this kind of arbitrary transform would mean Box2D would need to support ellipse (even sheered ones) which it doesn't support.
This only parts of the transform component that are used are:
X/Y position (Z ignored)
Z rotation (X/Y ignored)
X/Y scale (Z ignored)
The colliders are not part of the SpriteRenderer component so whatever it does or doesn't use isn't tied into any of the colliders.
参考:
http://forum.unity3d.com/threads/rotating-sprite-does-not-rotate-collider.212327/
- Collider2D碰撞检测异常-Rotating sprite does not rotate collider[Unity]
- collider 碰撞检测
- Sprite Kit 碰撞检测
- Unity碰撞(Collider)的深入理解
- Unity 碰撞器(Collider)与触发器(Trigger)
- Unity碰撞检测
- Unity 碰撞检测
- [Unity-4] 碰撞检测
- Unity Layout碰撞检测
- Unity 碰撞检测、射线
- Unity碰撞检测
- Unity碰撞检测。
- Unity 物理碰撞检测
- unity中的碰撞检测
- Unity 射线检测碰撞
- Unity UI检测碰撞
- unity中的碰撞检测
- unity之碰撞检测
- Oracle 的TO_DATE对日期处理
- UE正则表达式
- oracle备份
- Zookeeper的核心概念
- 第十一周项目6 回文素数(1)反序数
- Collider2D碰撞检测异常-Rotating sprite does not rotate collider[Unity]
- Hibernate:常用的主键生成策略
- 通过反射机制动态设置类的私有域
- linux各文件夹的作用
- 文件系统一之UBI文件系统简介
- 【DataGuard安装】Oracle单实例到RAC用duplicate active database做DataGuard之一
- 第十三周 项目1:(3)
- http访问Tomcat传参出现乱码
- 第十三周项目一数组大折腾(1)