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

How can I use BodyVelocity to move an object relatively?

Asked by 6 years ago

It seems pretty simple, but BodyVelocitys use absolute coordinates to move an object. How can I make it move relative to the objects orientation? I don't have any code because it is a simple request: Make a BodyVelocity move an object forward. Thanks.

1 answer

Log in to vote
0
Answered by 6 years ago

In a script, change the Velocity property of your BodyVelocity inside your part to the part's CFrame.lookVector:

local Part = script.Parent -- Assuming the script is inside your part
local BodyVelocity = script.Parent:WaitForChild("BodyVelocity")

BodyVelocity.Velocity = Part.CFrame.lookVector

Same concept can be aplied to move your part in other directions relative to its own position, just play around with your part's CFrame properties. Useful link.

Hope this helps. Have a good day!

Ad

Answer this question