How do I set a CFrame smoothly?

Hello, I have been working on an FPS framework but I am strugling with adding a walking animation to the system.

if char.Humanoid.MoveDirection.Magnitude > 0 then
	goalCFrame = goalCFrame *, cos, 0)
	goalCFrame = camera.CFrame * gunSettings.OffsetFromCamera

Here is what happens:

How do I change the goalCFrame variable smoothly?
Thank you!

To set a CFrame smoothly check out lerping!


local Part1 = --
local Part2 = --

local dur = 1 — Moving duration

local Part3 ="Part", workspace)
Part3.CFrame = Part1.CFrame:Lerp(Part2.CFrame, dur)

I did, but this happens:

Here is my code:

	if char.Humanoid.MoveDirection.Magnitude > 0 then
				goalCFrame = goalCFrame:Lerp(camera.CFrame * gunSettings.OffsetFromCamera *,cos,0), 0.1)

				goalCFrame = goalCFrame:Lerp(camera.CFrame * gunSettings.OffsetFromCamera, 0.1)

I’m sorry but I’m not exactly sure what is happening and what is supposed to be happening, are you talking about the jittering?

1 Like

Yes, it doesnt switch between the animations smoothly.

What if you make the duration a little longer

maybe look into springs and offsets like how the walkcycle works in