|Topic was automatically imported from the old Question2Answer platform.
I’m coding simple airplane physics, and I need to get the linear velocity of the RigidBody in a local space, in other words, relative to self. (So that I know the velocity on each individual local axis.)
I’ve tried the to_local() function, but this doesn’t work as intended, probably because it is meant to be used for position and not direction.
I know that for converting it from local to global space, one multiplies the vector with transform.basis; but how do I go the other way around?
It looks like that nobody has ever asked this question, so here I’m asking it now.
EDIT: My phrasing seems to be a bit confusing, because “a velocity relative to self” doesn’t exist. I mean that I need to get a rotated version of the velocity vector, so that the axes of it are identical with the axes of the RigidBody, but the global direction and magnitude remain the same.
velocity of the RigidBody in a local space, in other words, relative to self.
Excuse me, but “velocity relative to self” is not applicable term, by definition.
Probably you have meant some other situation, but you should properly describe your task.
sash-rc | 2021-12-21 07:28
I see… Yes, you’re right. I meant the direction to be relative to self.
So basically just a rotated version of the global linear velocity.
Let me edit the original question then…
QGames | 2021-12-21 07:35
Normally they use
xform_inv to convert rotations.
sash-rc | 2021-12-21 16:30