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
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)
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.
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