Godot Version
4.2.1
Question
I have an object that has a constant velocity of 1 m/s on the x-axis
If I now rotate the object by 90 deg on the y-axis I have to adjust the constant velocity to -1 m/s on the z-axis and set the x-axis to 0 m/s
Is there a way to make the constant velocity’s axis follow the rotation of the object so I don’t always have to update them?
Max
Yeah, you can multiply the object’s transform.basis
with the direction, that should give you exactly what you need. Quick code example:
var new_direction = transform.basis * old_direction
It might behave weirdly if the object has a scale that isn’t (1, 1, 1), but it looks like your object doesn’t have that problem.
Thanks @tayacan I ended up using the global_transform
var newVelocity = global_transform.basis.x * speedMultiplier
set_constant_linear_velocity(newVelocity)
That seems to work just fine for me 
1 Like