How would I make viewmodel animation smoother

Hi, I am working on my viewmodel framework and I have a basic grip on it but I ran into a problem.

I want to know how to make my viewmodel animations switch smoothly. For example, if I were to change from a walking state to a running state, it would smoothly change to a running state.

Here’s my code

function vhandler:Update(DT)
	if self.viewmodel then
		local rotation =
		local x,y,z = rotation:ToOrientation()
		self.swayCF = self.swayCF:Lerp(CFrame.Angles(math.sin(x) * self.swayAMT, math.sin(y) * self.swayAMT,0),0.1)
		self.lastCameraCF =
		self.viewmodel:SetPrimaryPartCFrame( * self.swayCF)
		if self.character:FindFirstChild("Humanoid") then
			local humanoid = self.character:FindFirstChild("Humanoid")
			--local MoveVector = Controls:GetMoveVector()
			--MoveVector =
			--	ThumbstickCurve(MoveVector.X),
			--	ThumbstickCurve(MoveVector.Y),
			--	ThumbstickCurve(MoveVector.Z)
			local speed = humanoid.WalkSpeed
			if speed >= 3 and speed < 11 then -- walking
				print("walking: "..speed)
			if speed >= 12 then
				print("sprinting: "..speed)

This function connects to a renderstep in a local script

1 Like

I should use WorldModel if you want the animation to run smoothly. Having just ViewModel for your arms will play the animation frame by frame. With WorldModel, this replicates the smoothness that you would see outside of ViewModel.

1 Like

I don’t know how to use worldmodel, I only use it for viewportframes, not viewmodels. Can you tell me how to use it?

It’s very similar to how you move your camera in viewportframe. I believe you insert a worldmodel into the viewportframe, then later putting whatever model you want to animate inside.