碰撞检测有BUG?

反馈碰撞检测的BUG

  • Creator 版本:3.6.2

  • 目标平台: 谷歌浏览器

      const a1 = new Vec2(270, 34)
    
      const a2 = new Vec2(270, 46)
    
      const rect = new Rect(263, 32, 15, 15)
    
      const boo = Intersection2D.lineRect(a1, a2, rect)
    
      console.log(boo)
    

这个应该会发生碰撞吧,但但是运行返回falseQQ浏览器截图20230101154715

官方看不到吗?

包含 不是 相交
1

public Rect (x ?: number, y ?: number, width ?: number, height ?: number) : Rect

构造具有指定的最小值和尺寸的矩形。

输入参数

名称 类型 描述
x number The minimum X coordinate of the rectangle.
y number The minimum Y coordinate of the rectangle.
width number The width of the rectangle, measured from the X position.
height number The height of the rectangle, measured from the Y position.

https://docs.cocos.com/creator/3.6/api/zh/class/math.Rect?id=Rect

public lineRect : (a1 : Readonly < Vec2 >, a2 : Readonly < Vec2 >, b : Rect) => boolean

测试线段与矩形是否相交
https://docs.cocos.com/creator/3.6/api/zh/class/Intersection2D?id=lineRect

好的谢谢,明白了

百度矩形包含线段即相交,cocos可能定义有点问题。

两个端点都在矩形外 但是穿过矩形也想交啊