Can't find good settings for viewmodel bobble effect

Hello, so I have been making a test viewmodel but I can’t find good settings for a bobble effect for it but this happens:


I have been testing settings for math.sin and cos for like 1 hour and I can’t find good settings.
Here is my code:
local script:

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local viewModel = workspace:FindFirstChild('ViewModel'):Clone()
local camera = workspace.Camera
viewModel.Parent = camera
local module = require(viewModel.Pistol.ModuleScript)
local idle = viewModel.AnimationController.Animator:LoadAnimation(viewModel.Animations.Idle)
local viewModelCFrame = CFrame.new()
viewModelCFrame = module.Pos
idle:Play()

game:GetService('RunService').RenderStepped:Connect(function()
	viewModel:SetPrimaryPartCFrame(camera.CFrame * viewModelCFrame)
	if humanoid.MoveDirection.Magnitude > 0 then
		viewModelCFrame = viewModelCFrame:Lerp(CFrame.new(-1 * math.sin(time() * 12), -.5 * math.cos(time() * 12),0 ), .1)
	else
		viewModelCFrame = viewModelCFrame:Lerp((module.Pos),.1)
	end
end)

Module:

local module = {}

module.Pos = CFrame.new(1,-1,0)



return module

Edit: here is the file: VIewModel.rbxl (82.8 KB)

Thank you!

I don’t understand what you would like to get, if you want to fix it like arsenal, that’s okay

1 Like

Yeah I want a gentle bobble effect.

Maybe it’s a bit flex isn’t it?

I’m trying to find good settings I have been messing arround for like an hour and can’t make it gentle.

Oh, Have you tried changing numbers?

Yes, I said I was changing the numbers for like an hour and can’t find good results.

Ah ok, can’t you contact the arsenal developers?

The head is perhaps too attached to the arms, try to change the position instead of the script

Is this what you want?

game:GetService('RunService').RenderStepped:Connect(function()
	viewModel:SetPrimaryPartCFrame(camera.CFrame * viewModelCFrame)
	if humanoid.MoveDirection.Magnitude > 0 then
		local iTime = os.clock()
		local bounce = math.sin(iTime*9)
		if bounce >= 0 then
			bounce = -bounce
		end
		viewModelCFrame = viewModelCFrame:Lerp(CFrame.new(math.cos(iTime*9),-1 + bounce, 0), .1)
	else
		viewModelCFrame = viewModelCFrame:Lerp((module.Pos),.1)
	end
end)
2 Likes

Thank you so much! It looks clean!

1 Like

Not much a scripter but, couldn’t you manually animate the bobbing? You can control it a whole lot easier that way. Considering you know the basics of animation it shouldn’t really be that hard.

1 Like

yes but its better to make it procedural so u dont have to put that much time on animations, but yes animation bob is totally possible but IMO procedural bob sometimes look much more majestic