I want to have a platform move from 1 position to another, at a constant rate of speed. Problem I am having with BodyPosition, is a lot of the time it starts fast and then slows down before it gets to the end.
These are my current values
Please don’t just tell me to trial and error. I’ve tried high/low numbers in either positions, varying amounts, etc. Nothing I do results in a smooth movement.
while true do
if not movePart or not movePart.Parent then break end
local Start = movePart:GetAttribute("Start")
local Finish = movePart:GetAttribute("Finish")
BodyPosition.Position = Finish
while (movePart.Position - Finish).Magnitude > 2 do wait() end
wait(2)
BodyPosition.Position = Start
while (movePart.Position - Start).Magnitude > 2 do wait() end
wait(2)
end
The parts also rotate for some reason? I have a BodyGyro inside of them, but they still get a weird offset rotation
Try using tweening to move them, much safer (in terms of movement) and much more smooth and customizable.
Edit: if you just want them to use body position, lower D (dampening) it slows it as it reaches it target, which makes it unprecise (same with body gyro)
You could use TweenService to move the BodyPosition’s Position rather than the part’s CFrame.
Or you can use a BodyMover or constraint move suited to this, like BodyVelocity or a PrismaticConstraint with an ActuatorType of Motor. That last option is probably the best for you?
I would suggest you use RocketPropulsion | Roblox Creator Documentation instead of BodyPosition just because you can set a MaxSpeed. If you want to use BodyPosition try to use very big values both for dampening and P (Try 1000, 2000, 10000 and see how they look).
I would not suggest you tween the BodyPosition’s position because that in itself will send a lot of data back and forth (possibly causing lag) if you animate on the server (which I assume you do).
For the rotation, make sure the BodyGyro has MaxTorque on all axis and is a high number (again try 1000, 2000, 10000) and same for the P (make it a big number).