How to maintain a moving object on its trajectory once it is rotated (like translateX) #326
Unanswered
etiennerin
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
My question might be simple, however i did not find any documentation or informations on how to do such thing.
I have a 3D cube on which i applied the useBox hook, i set it in motion through
velocity
and on the press of a directionnal arrow i want to rotate it right or left which i also managed with the use ofangularVelocity
. But once i want to move my object again (by pressing the up arrow to move it forward) the rotation is not taken into account and i would like to find a way of doing this(liketranslateX
does it) or some documentation. I would like to do this without anycontrols
/fpscontrols
/pointerlockcontrols
if possible.Here is the codesandbox of the complete project once i'll consider it done :
react-three-cannon-racing-game-starter
The problem starts at line 133 in the Player component.
Here is the exact code :
`moveForward() {
I also already read :
https://www.html5gamedevs.com/topic/24597-cannonjsmove-body-in-the-right-direction/
and it has a bit of a dry end
Thanks in advance for any information that might point in the right direction. I don't think i'm the only one having this basic issue, some documentation would be greatly appreciated !
Beta Was this translation helpful? Give feedback.
All reactions