I’m looking for a way to keep the Pet at a certain distance at all times, other than when in a specific range so that it can follow.
Is there any form of Maths I can use to adjust the WalkSpeed of the Pet so that it stays in constant motion and doesn’t approach the Player as shown below when making sharp turns:
local CanFollow = false
game:GetService("RunService").RenderStepped:Connect(function()
BodyGyro.CFrame = CFrame.new(Walker["Torso"].Position, Character["HumanoidRootPart"].Position)
if CanFollow then
Walker_Humanoid:MoveTo(Character["HumanoidRootPart"].Position)
else
Walker_Humanoid:MoveTo(Walker["Torso"].Position)
end
if (Walker["Torso"].Position - Character["HumanoidRootPart"].Position).Magnitude > Pyrona["Base"].Size.X / 2 then
if Character["Humanoid"].MoveDirection.X == 0 and Character["Humanoid"].MoveDirection.Z == 0 then
else
CanFollow = true
end
end
if Character["Humanoid"].MoveDirection.X == 0 and Character["Humanoid"].MoveDirection.Z == 0 then
CanFollow = false
end
Pyrona:SetPrimaryPartCFrame(Walker["Torso"].CFrame)
end)