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

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

Asked by
Teeter11 281 Moderation Voter
8 years ago

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

Log in to vote
0
Answered by 8 years ago

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.

Ad

Answer this question