How to make more fluent Viewmodel Arms

I’m currently attempting to create arms for my shooter game. I’d like to make my arms move similarly to the game Kat. As you can see, the arms move fluently when you turn. They continue moving after you stop and then come back to the middle (similar to the Back easingStyle)

I’ve heard that this can be achieved with springs, but I’m not sure of anything else.
If anyone knows how to create this effect, please let me know! Thank you. :slight_smile:

My current code:

runService.RenderStepped:Connect(function() 
     viewModelArms:WaitForChild("HumanoidRootPart").CFrame = workspace.CurrentCamera.CFrame 
end)

Footage from Kat:

External Media

Edit:
I found the spring module. However, I’m not sure how to make it work with my current code.
All help is appreciated!

2 Likes

You can probably use lerping to get that effect.

1 Like

But how do I make it look smooth? As you can see in the clip, the gun lags behind a bit and perfectly conserves the appropriate amount of momentum when I stop moving my camera.

Using lerping would result in the loss of that affect. Unless you had a different way to use lerping in mind.
I’d love to use springs, as those are physics based. I’m just not sure.

Thank you for the response!

Basically have the gun increment higher than the arms, making the arms move faster than the gun, but I haven’t learned how viewmodel arms works, so I could be wrong.

What I did is get the camera delta and rotate the arm by the reverse of that. I then play a tween to move it back to its original place every frame.

I’m still learning to program. Would you mind elaborating? Potentially with code examples.
Thank you for the response! Very helpful already.

Will do in a bit. Should switch devices to get the code.

1 Like

Here it is:
ViewmodelMC.rbxm (11.3 KB)
Here’s the most relevant code too:

RunService.RenderStepped:Connect(function()
	-- Bob arm when walking
	if CurrentlyBobbing then
		local BobTime = tick() * BobbingSpeed
		local yOffset = math.sin(BobTime) * BobbingAmount

		Camera.CFrame = Camera.CFrame * CFrame.new(0, yOffset, 0)
	end
	
	-- Move arm when rotating camera
	local MouseDelta = UserInputService:GetMouseDelta()
	Camera.CFrame = Camera.CFrame * CFrame.Angles(MouseDelta.Y/RotoBobbingDampener, MouseDelta.X/RotoBobbingDampener, 0)
	
	-- Smoothly return arm to main position
	local NewTween = TweenService:Create(Camera, TweenInfo.new(1), {CFrame = CameraPos})
	NewTween:Play()
end)

I’m not really worried about people stealing this since it’s mainly local anyway so yeah… Also some of the code there is slightly bad. Probably needs to be changed a lot for it to not need ViewportFrames.

Thank you!
However, I’m not sure how I could convert this to a viewmodel.
I apologize, I know that I’m asking a lot. However, if you know how to convert this to work with this model, please let me know!

viewmodel.rbxm (76.1 KB)

Once again, I understand this would be a lot to do.
Apologies and thank you again! :slight_smile: