How to apply velocity to a 3d body the angle it looks at?

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

My question is quite straightforward i guess, how do i get the angle a rigidbody is looking at and translate it into velocity? and/or apply velocity to its sides like a player moving mechanism? i can find almost nothing online, and all i found were about 2d

:bust_in_silhouette: Reply From: PrecisionRender

Like, apply a force in the direction your body is facing? That can be easily done. In Godot, we can use transform.basis to alter a forward force to point in the direction we are facing. Here is what the code would look like:

add_central_force(Vector3(0, 0, -50) * -transform.basis.z)