Skip to content

Best way to set up moving platforms with /cannon #1949

Answered by khoneychurch
khoneychurch asked this question in Q&A
Discussion options

You must be logged in to vote

After tinkering for a day, here's what I ended up doing:

(A quick note on the cause of this issue; it seems that this is a natural result of having zero friction on my defaultCollisionMaterial, but this is necessary so the player doesn't stick to walls. I did play with friction a bit, but ultimately decided it had to remain at zero for the best platforming experience)

To lock the x (or y) position on the moving platform, I found I could set type:"KINEMATIC" in the useBox hook. This fixed the jitter, then I just used api.position.set to update the position on every frame (in useFrame).

To keep the character moving along with the platform, I check the collision object to see if he landed on…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by khoneychurch
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants