Hello Everyone! I’m here to ask how to make viewmodel sway like on this video. I’ve already asked that type of question, but I was asking about how to get BodyCam camera effect. And I did a pretty good job but I still working on it.
But now I’m curious how to make the viewmodel and camera sway like Unrecord have. I tried a lot of variants, I tried to play with sway values, but I don’t get what I want and needed.
Here is what I have now (It’s unfinished and I can’t take a video to show sway that I have right now lol):
And here is the sway part of script:
(I’m using spring module)
mouse.TargetFilter = framework.viewmodel
script.Values.CurrentSlot.Value = framework.currentSlot
script.Values.Equipped.Value = framework.viewmodel
local vignetteValue = 1.95
local cameraVignette = workspace.Main.Camera
tweenService:Create(cameraVignette, TweenInfo.new(0.035, Enum.EasingStyle.Exponential), {
CFrame = (camera.CFrame + camera.CFrame.LookVector * vignetteValue)
}):Play()
if hud and character then
hud.Ammo.Ammo.Ammo.Text = framework.module.ammo
hud.Ammo.Ammo.MaxAmmo.Text = framework.module.storedAmmo
hud.Main.GunName.Text = framework.viewmodel.Name
hud.Main.Type.Text = framework.module.fireMode
end
if overheat >= 15 then framework.viewmodel:FindFirstChild('Muzzle').Overheat.Enabled = true
elseif overheat < 15 then
framework.viewmodel:FindFirstChild('Muzzle').Overheat.Enabled = false
end
local updatedrecoilspring = recoil:update(dt)
swayAngCF = CFrame.Angles(0, 0, math.rad(updatedrecoilspring.x) * 35)
camera.CFrame *= CFrame.Angles(math.rad(updatedrecoilspring.x), math.rad(updatedrecoilspring.y), math.rad(updatedrecoilspring.z))
local mouseDelta = uis:GetMouseDelta()
sway:accelerate(Vector3.new(mouseDelta.x/60, mouseDelta.y/60, 0))
--local roll = GetRollAngle() * 2
--rot_viewmodel = rot_viewmodel:Lerp(CFrame.Angles(0, 0, rad(roll)), 0.075)
--leanCF *= rot_viewmodel
local swayVec = sway.p
local TSWAY, XSSWY, YSSWY = swayVec.z, swayVec.X, swayVec.Y
local sway_cf = CFrame.Angles(YSSWY,XSSWY,XSSWY)
if humanoid then
local sway_nd = sway_n:update(dt)
local rot = camera.CFrame:ToObjectSpace(lastCameraCF)
local X, Y, Z = rot:ToOrientation()
swayCF = swayCF:Lerp(CFrame.Angles(math.sin(X) * currentSwayAMT, math.sin(Y) * currentSwayAMT, 0) * sway_cf:inverse(), .1)
lastCameraCF = camera.CFrame
if humanoid then
if framework.viewmodel ~= nil and framework.module ~= nil then
if humanoid.MoveDirection.Magnitude > 0 then
local charspeed = humanoid.WalkSpeed
if charspeed == 8 then
bobOffset = bobOffset:Lerp(CFrame.new(
0.025 * (charspeed/10) * math.sin(tick() * 8),
0.025 * (charspeed/10) * math.cos(tick() * 16),
0
) * CFrame.Angles(
math.rad( 1 * (charspeed/10) * math.sin(tick() * 16) ),
math.rad( 1 * (charspeed/10) * math.cos(tick() * 8) ),
math.rad( 1 * (charspeed/10) * math.cos(tick() * 8) )
), 0.1)
isSprinting = false
elseif charspeed <= 11 then
bobOffset = bobOffset:Lerp(CFrame.new(
0.05 * (charspeed/10) * math.sin(tick() * 8),
0.05 * (charspeed/10) * math.cos(tick() * 16),
0
) * CFrame.Angles(
math.rad( 1 * (charspeed/10) * math.sin(tick() * 16) ),
math.rad( 1 * (charspeed/10) * math.cos(tick() * 8) ),
math.rad( 1 * (charspeed/10) * math.cos(tick() * 8) )
) * framework.module.sprintCF, 0.1)
isSprinting = true
end
else
if humanoid then
if not isAiming.Value then
humanoid.WalkSpeed = 8
--bobOffset = bobOffset:Lerp(CFrame.new(
-- 0.005 * math.sin(tick() * 1.5),
-- 0.005 * math.cos(tick() * 2.5),
-- 0
-- ), 0.1)
bobOffset = bobOffset:Lerp(CFrame.new(0, -humanoid.CameraOffset.Y/2, 0), .1)
bobOffset = bobOffset:Lerp(CFrame.Angles(math.cos(tick() * 1) * .06, 0, 0), .1)
elseif isAiming.Value then
bobOffset = bobOffset:Lerp(CFrame.new(0, humanoid.CameraOffset.Y, 0), .1)
end
end
isSprinting = false
end
end
for i, v in pairs(camera:GetChildren()) do
if v:IsA("Model") then
v:SetPrimaryPartCFrame(camera.CFrame * swayCF * swayAngCF * aimCF * bobOffset * leanCF * framework.module["idleCF"])
updateCameraShake()
end
end
end
I can give more information, just let me know.
If someone can help me or give tips to how I can make it, then It would be really appreciated! Thanks.