2D Collider Trigger detection no need Rigibody2D?

It’s not working, I try to research but have no doc for this case, thank u.

this.collider.on('onTriggerEnter2D', this.onTriggerEnter, this);
    onTriggerEnter(event: ITriggerEvent) : void {
        console.log('Trigger entered:', event.otherCollider.node.name);
        // Your logic here
    }

If you are using Cocos Creator 3.x
try this: 2D Contact Callback | Cocos Creator

1 Like

I don’t use Rigibody2D, just use Collider to trigger <3

I’m pretty sure that both the trigger and the object being detected both have to have a rigid body in order for the box to the engine to identify it.

If you need the trigger to not have collisions, then it can be at a “sensor“ which should be a checkbox.

If you need the thing that’s been detected to not be affected by physics then you could make it “static“ and then keep moving it via whatever input you have.

it have been changed to 3.8.x, so in 3.8.x not only needs collider component but also rigidbody component, and you can change it by refering link: Is Engine's Error? - #11 by Tom_k. BTW, we have built a issue(collide Events needs rigidbody in Cocos 3.8x but dont need in Cocos 3.7.4 · Issue #17541 · cocos/cocos-engine · GitHub) to address it.