BodyPosition Slowing down when reaching target

Hello there. I created a simple script where there’s an orb that follows you around almost like a pet. The thing is that I want the orb to stay at a constant velocity. Within the script, I made it so that the orb will float towards my HumanoidRootPart and damage me but the orb would slow down when it’s close to my HumanoidRootPart. The system is like a zombie system but using a sphere object.

Orb Following Gif:
https://i.gyazo.com/1b3ed0e263ad3912e9a07638786acd7c.gif

Again, I want to make it so that the orb stays at a constant velocity from start to finish which is the HumanoidRootPart.

BodyPosition uses a proportional derivative controller iirc. Lowering the D value lowers the dampening effect that will slow it as it nears target, but if you set it too low it’s going to overshoot and possibly oscillate.

1 Like

Are you using TweenService? By default, tween service will automatically slow down the rate of change once it nears the end value.

Can we see your script?

Im using BodyPosition for this system. And I don’t know if I’m using this Lua text correctly since I am quite new to this.

local bp = Instance.new('BodyPosition')
bp.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bp.P = manaGiven[2]
bp.Parent = enemy

local bg = Instance.new('BodyGyro')
bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bg.Parent = enemy

while wait() do
	
	if enemy:FindFirstChild('BodyPosition') and enemy:FindFirstChild('BodyGyro') then
		enemy.BodyPosition.Position = hrp.Position + hrp.CFrame.LookVector*1
		enemy.BodyGyro.CFrame = hrp.CFrame
end
end

Adjust the D force.

It will take a bit of trial and error of fiddling with it until its within a tolerance for your orb’s mass.