rapier.js
rapier.js copied to clipboard
why `wolrd.contactsWith` callback never gets called?
const bodyDesc = RigidBodyDesc.dynamic()
.setTranslation(startPos.x, startPos.y)
.setLinearDamping(0)
.setLinvel(-this.speed, 0)
this.rb = Physics.instance.world.createRigidBody(bodyDesc);
const colliderDesc = ColliderDesc.ball(this.size);
const collider = Physics.instance.world.createCollider(
colliderDesc,
this.rb
);
Physics.instance.world.contactsWith(collider, (collider2) => {
console.log(
"🚀 ~ file: Bullet.physics.ts:58 ~ BulletPhysics ~ Physics.instance.world.contactsWith ~ collider2:",
collider2
);
});
i don't know why but my callback never gets called. I couldn't find any examples!
Have you found the reason, is not working too
Popping in just to say that this happens for me too. Also happens for intersectsWith
. Neither seem to actually get called.
I'm pretty confident that the masks are set up properly because I can see the event coming through drainCollisionEvents
.
These methods are not registering an event handler that will get called when a contact/intersection is detected.
The callback are called only if there is any contact at the moment you call contactsWith
. So, whenever you need to check these contacts (typically once per frame, after the physics step), you need to call .contactsWith
again.
OH! Well that's my problem. I must've misunderstood that in the docs. Thanks Seb!