Make a bodyvelocity use local space?

I’m currently making a floating car I call ‘floaty’.
When someone presses W for example, it needs to move forward but it does that in the world space in stead of local space, so if I would press W when floaty isn’t in the 0,0,0 orientation, it would move to a completely different direction.
(I’m using a bodyvelocity.)
I’m not expert in this.
Can anyone help?

3 Likes

I believe simply multiplying a CFrame’s LookVector by the Velocity you want to use should work.
Multiplier would be the amount of studs you want to go (Velocity) in the direction of the part’s LookVector.

E.G
Velocity = Part.CFrame.LookVector * Multiplier;

3 Likes

Going to plug here: VectorForce automatically applies force in relative space depending on what your systems require: either relative to the object, another object or world space. It’s part of the new body movers set shipped to the constraints system, which superseded legacy body movers (BodyX).

9 Likes

If you have a Vector represented in Object space, you can transform it to World space before assigning it to the the BodyVelocity using CFrame.VectorToWorldSpace

local objectRelativeVelocity = Vector3.new(0, 0, -10); -- velocity of 10 studs forward relative to myself
part.BodyVelocity.Velocity = part.CFrame.VectorToWorldSpace(objectRelativeVelocity);
2 Likes