Issue with positioning pets

Hey, how do i make the pet not be locked on to the player’s position? if the player has an animation that moves the character (i.e player looks down) the pets would move up. I tried raycasting but couldnt make it work.
video:

External Media

here is the code:

local x = radius * math.cos(angle)
local z = radius * math.sin(angle)
local y = 0

local offsetPosition = playerCF * CFrame.new(x, y, z)
local petCF = pet:GetPivot()
local newPos = petCF.Position:Lerp(offsetPosition.Position, lerpSpeed)		
	
local newPetCF = CFrame.new(newPos,newPos + playerDirection)
pet:PivotTo(newPetCF)```

I’m assuming you’re using the Upper torso for the direction/position variables?

If you swap it to the humanoidrootpart, the animations should have no effect on it, stabilizing the pets. If you’re not using animations and moving the entire character, you could possibly normalize the direction so it doesn’t take into account the up/down movement

1 Like

Yea thanks, i was using character:GetPivot() for playerCF.

1 Like