How to add_force on rigid body depending its current z-rotation

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

I have a rigid body cube and I’ve used add_force method to move it upwards, but the force is always pointed upwards, even if the cube is rotated. I’m only rotating the cube on the z axis

How do I the add the force to “point” in the current rotation/direction of the cube/rigid body? Similar to the game Asteriods.

This what I’m doing now:

if(Input.is_action_pressed(“throttle”)):
add_force(Vector3(0,10,0),Vector3(0,0,0))

:bust_in_silhouette: Reply From: BraindeadBZH

I had the same exact problem, I used the transform.basis.xformfunction of body on the force and position vectors.