How to convert a torque impulse value to global coordinate system as Camera moves around

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ouyang

Dear all, recently I’m using Godot to create a ball game. To simplify the question, assuming in the physics world there’s only one RigidBody called ball, a Camera which can be rotated around with ball.

Now I wanna give the ball a torque by using apply_torque_impulse method, for example this torque value is Vector3(0, 10, 0) which means (for now) rotate the ball along Z axis.

Then, I rotate the Camera around the ball for 90 degrees for example (the UP is Y axis always), and here the problem comes:
Before the camera move, the impulse value Vector3(0, 10, 0) will let it rotate backwards (Z axis), but after moving, the same value cannot be used anymore, because the current correct axis should be X axis as I still want it to roll backwards!

So my question is how to convert/transform that value to the correct one as Camera moves to different angle degrees.

Thanks a lot.

:bust_in_silhouette: Reply From: CallMeRED

Forces are applied based on the 3D world global coordinates. after you move your camera, if you apply the same force Vector3(0, 10, 0), it’s normal the ball rotates the same way (for the 3d world)
you only see it roll backward because your camera “point” of view changed.

The 3D world does NOT move with your camera.

you should use node transform.basis.x, y and z if you want to control position and direction, not Vector.

I suggest you to read this : Using 3D transforms