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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

One-way-platforms by adding PhysicsHooks to world.step issue #597

Open
driescroons opened this issue Jan 22, 2024 · 0 comments
Open

One-way-platforms by adding PhysicsHooks to world.step issue #597

driescroons opened this issue Jan 22, 2024 · 0 comments

Comments

@driescroons
Copy link

driescroons commented Jan 22, 2024

Hey 馃憢 I recently came across this example in rust for one way platforms in rapier and tried to recreate the effect.

I'm currently able to let the ball pass through the platform by adding a PhysicsHook

Screen.Recording.2024-01-22.at.00.58.46.mov

However, I'm only able to disable the collision check. I'm not able to access the RigidBody's linvel, or translation and it results in an recursive use of an object detected which would lead to unsafe aliasing error. I'd like to check if the ball is above the platform to enable the collision check again.

image

How does this currently work?

In order to get this to work we need to be able to pass an additional hooks param to world.step(eventQueue, hooks) of type PhysicsHooks.

In order for us to get access to this in components, I added filterContactPairHooks and filterIntersectionPairHooks to useRapier.

This allows us to register a hook in our OneWayPlatform.jsx demo that we can push to filterContactPairHooks. We also need to make sure we set setActiveHooks to one for either our ball or platform.

This works, but when I try to get access to body's linvel or translation in the hook, from either the ref, or the params I get the above error. How am I able to access the body in that hook?

Code: #603

Run locally

  • yarn
  • cd demo
  • yarn dev
  • click to let the ball jump
@driescroons driescroons changed the title Adding PhysicsHooks to world.step issue One-way-platforms by adding PhysicsHooks to world.step issue Jan 29, 2024
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

1 participant