hey recently started to learn about 3d(threejs) and physics(rapier), I want to control the box movement like a car with arrow keys, but I have difficulty fixing the movement in the right direction with physics.
here is a code example https://codesandbox.io/s/q-stackoverflow-9j4sf1?
inside the useFrame I want to know what should I need to insert the useFrame look like this:
useFrame((state, delta) => {
if (ref.current) {
const box = ref.current;
/// what i should insert in this area
// w/ArrpUP click
if (controllers.forward.isPress) {
// What do I need to insert so that the box moves forward
}
// s/ArrpDown click
if (controllers.backward.isPress) {
// What do I need to insert so that the box moves backward
}
// L/ArrpLeft click
if (controllers.left.isPress) {
// What do I need to insert so that the box rotate left
}
// R/ArrpRight click
if (controllers.right.isPress) {
// What do I need to insert so that the box rotate right
}
}});
thanks