I think you could achieve this by using xform
function and passing it a vector like Vector3(0,0,-1)
(assuming you are in 3D space, Vector2 if you are in 2D).
The idea here is, that xform
will get the movement relative to the node, where -z axis is forward, and then return coordinates in global space, which you can use for movement, for example with move_and_slide()
or setting linear_velocity
of a rigid body.
I use this technique to fire a bolt from a crossbow, held by the character and the bolt should be fired in the current direction the crossbow is pointing, not towards mouse or player.