Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why wolrd.contactsWith callback never gets called? #241

Open
TheMetaverseEngineer opened this issue Jul 15, 2023 · 4 comments
Open

why wolrd.contactsWith callback never gets called? #241

TheMetaverseEngineer opened this issue Jul 15, 2023 · 4 comments

Comments

@TheMetaverseEngineer
Copy link

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!

@wezzzyang
Copy link

Have you found the reason, is not working too

@Tresky
Copy link

Tresky commented Apr 14, 2024

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.

@sebcrozet
Copy link
Member

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.

@Tresky
Copy link

Tresky commented Apr 14, 2024

OH! Well that's my problem. I must've misunderstood that in the docs. Thanks Seb!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants