It’s not working, I attempt to analysis however haven’t any doc for this case, thank u.
this.collider.on('onTriggerEnter2D', this.onTriggerEnter, this);
onTriggerEnter(occasion: ITriggerEvent) : void {
console.log('Set off entered:', occasion.otherCollider.node.title);
// Your logic right here
}
If you’re utilizing Cocos Creator 3.x
do this: 2D Contact Callback | Cocos Creator
1 Like
I don’t use Rigibody2D, simply use Collider to set off
I’m fairly certain that each the set off and the article being detected each must have a inflexible physique to ensure that the field to the engine to establish it.
In the event you want the set off to not have collisions, then it may be at a “sensor“ which ought to be a checkbox.
In the event you want the factor that’s been detected to not be affected by physics then you possibly can make it “static“ after which hold shifting it by way of no matter enter you will have.
it have been modified to three.8.x, so in 3.8.x not solely wants collider part but in addition rigidbody part, and you’ll change it by refering hyperlink: Is Engine’s Error? – #11 by Tom_k. BTW, we now have constructed a concern(collide Occasions wants rigidbody in Cocos 3.8x however dont want in Cocos 3.7.4 · Difficulty #17541 · cocos/cocos-engine · GitHub) to deal with it.