I would like to know how I’d do a slight shake for a viewmodel like this, and the breath-holding and the exaggerated shake when breathing again.
I would like to know how I’d do a slight shake for a viewmodel like this, and the breath-holding and the exaggerated shake when breathing again.
Is this a video of your game, or somebody elses game?
Well you could use randomness? Maybe even perlin noise or tweening randomness if you want to be fancy. I also suggest scaling the randomness down slowly overtime because realisticlly the person would start to hold the gun more steady, especially if it’s a sniper.
viewport:PivotTo() -- set to where you want viewmodel to be
-- then offset with randomness
viewport:PivotTo(viewport:GetPivot() * CFrame.new(math.random()/5,math.random()/5,0))
Is this meant to go with Runservice.Renderstepped?
Whereever you have a loop or connection to update the viewmodel, you should translate the pivot with randomness like this.
This part of the script handles gun sway, I think I should put it here, but how would I do so?
for i,v in pairs(cam:GetChildren()) do
if v:IsA("Model") then
v:SetPrimaryPartCFrame(cam.CFrame * swaycf * aimcf * boboffset)
updatecamshake()
end
end
end
This would be how:
for i,v in pairs(cam:GetChildren()) do
if v:IsA("Model") then
local offset = swaycf * aimcf * boboffset
local random = CFrame.new(math.random()/5,math.random()/5,0)
v:PivotTo(cam.CFrame * offset * random)
updatecamshake()
end
end
I don’t know what updatecamshake()
does though.
This works, but to clarify, to lessen the shake, would the number to divide the math.random() by be lower or higher?
You would divide by a higher number so the effect is less. You can also multiply by a smaller number to make the effect less. Maybe you can use an amplitude NumberValue which you can tween so the effect looks better?
Sorry, I’m not really that good at the math stuff and CFrames, so I’d have problems finding out how the tween NumberValue would work with the CFrame.new().
local Amp = Instance.new("NumberValue")
Amp.Value = 0
for i,v in pairs(cam:GetChildren()) do
if v:IsA("Model") then
local offset = swaycf * aimcf * boboffset
local random = CFrame.new(math.random()*Amp.Value,math.random()*Amp.Value,0)
v:PivotTo(cam.CFrame * offset * random)
updatecamshake()
end
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.