Best way to set up moving platforms with /cannon #1949
-
Trying to figure out the best way to set up a moving platform with cannon, currently my two main problems are:
Screen.Recording.-platform.movThanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
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 top of a moving platform (which I can also get the props for that platform from), then I just apply them to the character on every frame. I'm sure there's a better/tighter way to handle this, I'm still very much open to suggestions. But at least this got me to MVP Screen.Recording.2021-12-29.at.12.32.37.PM.mov |
Beta Was this translation helpful? Give feedback.
-
maybe this helps? https://codesandbox.io/s/arkanoid-2yqpv |
Beta Was this translation helpful? Give feedback.
-
@khoneychurch did you find any optimized/native solution? |
Beta Was this translation helpful? Give feedback.
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…