Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

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.

0
You're awesome! Thank you! vislbIe 4 — 5y
Ad

Answer this question