I am trying to figure out how to make the pets have a smooth transition to being still to bobbling when a player moves.
RenderStepped:Connect(function(deltaTime)
for player : Player, Pets : {Model} in pairs(PetHandler.Loaded_Pets) do
local Character = player.Character
if not Character then continue end
local HumanoidRootPart = Character.PrimaryPart :: BasePart
local Humanoid = Character:FindFirstChild('Humanoid') :: Humanoid
for index, Pet : Model in pairs(Pets) do
local PrimaryPart = Pet.PrimaryPart :: BasePart
local angle = math.rad((index - 1) * (360 / #Pets))
local offset = Vector3.new(math.cos(angle), 0, math.sin(angle)) * Radius
local start_position = HumanoidRootPart.Position + offset + Vector3.new(0, HoverHeight, 0)
local hover_offset = math.sin(os.clock() * HoverSpeed + index) * HoverAmplitude
local target_position = if Humanoid.MoveDirection == Vector3.zero then HumanoidRootPart.Position + offset + Vector3.new(0, HoverHeight, 0) else HumanoidRootPart.Position + offset + Vector3.new(0, HoverHeight + hover_offset, 0)
local target_cframe = CFrame.new(target_position, HumanoidRootPart.Position)
PrimaryPart.CFrame = target_cframe
end
end
end)
Video of the not smooth transitions: