How can I smoothly move a rootpart with an animation?

I’m working on a movement system, and part of that system is moving the character with animations, such as when they mantle and stuff, the solution I’ve found is pretty good, on the second to last frame of the animation i save the position of the torso, then on the last frame i recenter the torso, and i teleport the HumanoidRootPart to the saved position of the torso.

However I’ve found that there’s this really annoying issue where the camera teleports back and forth instantly, and it’s completely ruining the movement

here’s an example:
https://gyazo.com/b8bdb8a01acba055d80b20698f41b1e1

and here’s my code:

function module.Play(Player,AnimationTrack : AnimationTrack,TransitionTime)
	local Character : Model = Player.Character
	local Humanoid : Humanoid = Character:FindFirstChild("Humanoid")
	local HumanoidRootPart : Part = Character:FindFirstChild("HumanoidRootPart")
	local Animator : Animator = Humanoid:FindFirstChild("Animator")
	
	HumanoidRootPart.Anchored = true
	Camera.AutoRotate = false
	
	AnimationTrack:Play(TransitionTime)
	local TargetPosition = Vector3.new(0,0,0)
	local Dir = HumanoidRootPart.CFrame * CFrame.new(0,0,-999)
	
	local PreTeleportConnection = AnimationTrack:GetMarkerReachedSignal("PrepareTP"):Connect(function()
		TargetPosition = Character.Torso.Position
	end)
	
	AnimationTrack:GetMarkerReachedSignal("Teleport"):Wait()
	
	HumanoidRootPart.CFrame = CFrame.new(TargetPosition,Vector3.new(Dir.Position.X,TargetPosition.Y,Dir.Position.Z))
	
	PreTeleportConnection:Disconnect()
	Camera.AutoRotate = true
	HumanoidRootPart.Anchored = false
end

the issue only really appears at a high frame rate so it’s only visible in the first clip, but it really depends when it occurs, any help would be greatly appreciated.

The issue probably because the camera is subjected to movement during the animation as well and you are not setting its position back. Maybe try setting the camera subject to the rootpart?

i’m using a custom camera, but it follows the heads position at all times, i’m pretty sure it’s something with the animation not being instant, however i can’t really shorten the distance between keyframes

well, i think you can’t “fix” the smooth rootpart problem, would be a big headache… one trick is to tween the camera (not the rotation, only the position)