What solutions have you tried so far?I haven’t actually tried anything because I’ve never seen anyone do this with lerp before.
Code:
local LERP_ALPHA = 0.08;
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
local character = chr
local hrp = character:WaitForChild("HumanoidRootPart")
local parts = {}
local numberOfParts = 4
for _ = 1, numberOfParts do
table.insert(parts, game.ReplicatedStorage.Part:Clone())
end
for i, part in pairs(parts) do
part.Anchored = true
part.CanCollide = false
part.Parent = workspace
end
local fullCircle = 2 * math.pi
local radius = 10
local function getXAndZPositions(angle)
local x = math.cos(angle) * radius
local z = math.sin(angle) * radius
return x, z
end
game:GetService("RunService").Heartbeat:Connect(function(step)
for i, part in pairs(parts) do
local petCframe = part.CFrame
local characterCframe = hrp.CFrame
local angle = i * (fullCircle / #parts)
local x, z = getXAndZPositions(angle)
local position = (hrp.CFrame * CFrame.new(x, 0, z))
local newCframe = petCframe:Lerp(position, LERP_ALPHA)
part.CFrame = newCframe
end
end)
end)
end)
Doesn’t Lerp interpolate a point between your position and the pet position? If you wanted the pet rotation to remain fixed around you at a certain radius, why not fix that radius? why use Lerp?