Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What math is involved to change BodyVelocity Velocity to part Orientation?

Hello, I have a part with a Body Velocity inside of it. The body velocity only moves the part based on a fixed X,Y,Z axis. For example, 0,2,0 gives the part an upward Velocity while 0,0,2 gives the part a forward Velocity no matter the part orientation. So, my question is what math is involved with making the part's BodyVelocity Velocity equal said value based on the part Orientation. A part with an Orientation of 45,0,0 and a Velocity of the same Orientation does NOT give the part a forward force based on the Orientation. I have pictures provided below of 2 parts, one facing upwards 45 degrees, and another turned 45 degrees.

http://prntscr.com/o5orym -- Upwards

http://prntscr.com/o5os74 -- Turned

1 answer

✓ Accepted answer

Using the part's CFrame, we can take its lookVector to feed to the BodyVelocity.

lookVector gives us the Vector3 value relative to world which is its direction

BodyVelocity.Velocity=part.CFrame.lookVector

By manipulating that CFrame, you can change the direction of its lookVector when feed to BodyVelocity too.

1 comment

0

You're awesome! Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.