cocos-engine icon indicating copy to clipboard operation
cocos-engine copied to clipboard

在碰撞检测回调中setPosition无效

Open aaadddfgh opened this issue 1 year ago • 1 comments

Cocos Creator version

3.6

System information

edge

Issue description

使用box2d作为物理系统时,在碰撞检测回调对相撞物体调用setPosition无效

Relevant error log output

No response

Steps to reproduce

我需要在某个物体检测到碰撞时,让碰撞到它的物体瞬移,就是以下代码中的b

onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {

          let b:Node = this.something;

           b.setWorldPosition(50, 900, 0);

        }

但这段代码不能实现预期的效果

Minimal reproduction project

No response

aaadddfgh avatar Aug 22 '23 21:08 aaadddfgh

能提供个 demo 吗?

minggo avatar Dec 27 '23 02:12 minggo