Hello, how would you create a Viewmodel sway that rotates with the camera if that makes sense. Sort of like in this video, Sway demo
Whenever they turn their camera, their viewmodel rotates and stays in that angle depending on where you are looking. Currently I’m using springs for the bobbing.
if Springs.Bobbing and Springs.Sway and Root then
local Bobble = Vector3.new(GetBobbing(6), GetBobbing(10), GetBobbing(1))
local MouseDelta = UserInputService:GetMouseDelta()
local MouseDeltaX = MouseDelta.X
local MouseDeltaY = MouseDelta.Y
-- Shove Springs --
Springs.Bobbing:shove(Bobble / 5 * (Root.Velocity.Magnitude) / Bobbing_Division)
Springs.Sway:shove(Vector3.new(-MouseDeltaX / Sway_Division, MouseDeltaY / Sway_Division, 0))
-- Springs Updater --
local UpdatedBobbing = Springs.Bobbing:update(DT)
local UpdatedSway = Springs.Sway:update(DT)
local UpdatedFiring = Springs.Firing:update(DT)
if Viewmodel.CurrentVM then
-- Sway Updater --
local SwayX = UpdatedSway.X
local SwayY = UpdatedSway.Y
Viewmodel.CurrentVM.HumanoidRootPart.CFrame *= CFrame.new(SwayX, SwayY, 0)
-- Bobbing Updater --
local BobX = UpdatedBobbing.X
local BobY = UpdatedBobbing.Y
Viewmodel.CurrentVM.HumanoidRootPart.CFrame *= CFrame.new(BobX, BobY, 0)
-- Firing Updater --
local FireX = UpdatedFiring.X
local FireY = UpdatedFiring.Y
local FireZ = UpdatedFiring.Z
Viewmodel.CurrentVM.HumanoidRootPart.CFrame *= CFrame.new(FireX, FireY, FireZ)
end
end
Here’s the result of my code, it sways. But not in the way I want it to.