Hello,
I created a sort of viewmodel that rotates on the Y-axis based on how much the camera rotates on the Y-axis. This is to make it feel less rigid and more “realistic.”
local function Update(self)
local CamCF = self.Camera.CFrame
local Yaw = math.atan2(CamCF.LookVector.X, CamCF.LookVector.Z)
local RotatedCF = CamCF * CFrame.Angles(0, Yaw * 2, 0)
self.Viewmodel:PivotTo(RotatedCF)
end
However, if you rotate the camera too far, the viewmodel goes off-screen and does a full 360-degree turn due to the multiplied rotation. How can I limit the viewmodel’s rotation so it only rotates to the left/right with a max angle?