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

how do i make a bodyposition move towards the goal at a constant speed?

so basically i have a part and i want that part to move towards its goal at the same speed no matter how far the goal is away.

how can i go about doing this?

thanks in advance

1 answer

This is an example script with 2 parts, A and B.

Part B has its studs removed so it can freely move.

if P exceeds max force then it should always move at max force towards its goal, the distance to this goal has no effect on its speed. Also take into account that you will be fighting gravity so you may need more force on larger objects.

local bodyForce = Instance.new("BodyPosition", script.Parent)
bodyForce.MaxForce = Vector3.new(5000,5000,5000) -- this controls the max force which will be applyed to x,y,z while trying to reach its goal
bodyForce.P = 1000 -- how fast it will reach its goal but not will not exceed max force

bodyForce.Position = game.Workspace.PartA.Position --- move part b to part a

Hope this helps.

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