Gun arms lerp, but don't lerp relative to the camera, and trail behind in 3D Space

Hello :wave:

How do I CFrame :Lerp() an object so that it moves relative to the camera and doesn’t just trail behind it, but still maintains the non-exact swinging motion when I spin around my mouse

The Code:

local function ArmHandler()
		coroutine.resume(coroutine.create(function()
			while true do
			 	if FirstPersonV.Value == true then
					local CameraCF = (Camera.CFrame * CFrame.new(0,-2,-1))
					for i = 1, 5 do
						ArmRig.PrimaryPart.CFrame = (prevCameraCF:Lerp(CameraCF, i/5))
						RunService.RenderStepped:Wait()
					end
					prevCameraCF = CameraCF
				else
					break
				end
			end
		end))
	end

Thanks!

Keep the offset of the gun from the camera to the arm rig to the gun static, and interpolate only when the direction of the camera changes.

1 Like

The Arm Rig is holding the gun which is a welded tool, so it doesn’t move. On the other hand, how would I interpolate the direction of the camera changes using Lerp?

While I’m not exactly sure why it does this precisely, your method to looping is… Odd.
Try using render stepped? If not, then try spawn() instead of coroutines. Sometimes lerping causes things to lag behind, as well. You may just want to constantly set the CFrame to where you want it every frame instead of lerping

He should be using Slerp for this and instead only interpolate the angle.