So I’ve managed to find out how the spring module works, However I have an issue.
The camera seems to be multiplying itself every time and doesn’t have a set origin point. I have partially found a solution which is rather how I want it to look like.
To add, The Spring module I’m using is by Quenty.
Basically, I want the camera to offset without losing where its origin is.
Solved!!
I have found the solution, the solution might have to do with :ToObjectSpace()!
Viewmodel.Camera.CFrame = workspace.CurrentCamera.CFrame
Viewmodel.RecoilPart.CFrame = Viewmodel.Camera.CFrame*camreq
CameraRecoilSpring:Impulse(chosen)
local RecoilOffset = CFrame.new()
local newCamCF = Viewmodel.Camera.CFrame:ToObjectSpace(Viewmodel.RecoilPart.CFrame)
if oldCamCF then
local _,_,z = newCamCF:ToOrientation()
local x,y,_ = newCamCF:ToObjectSpace(oldCamCF):ToEulerAnglesXYZ()
RecoilOffset = CFrame.Angles(x/2,y/2,z)
end
oldCamCF = newCamCF
Camera.CFrame *= RecoilOffset:Inverse()
To Explain, Inside the viewmodel, there is a RecoilPart. This is used for the offset of the camera. I have taken the code off this devforum post. Which is for animating the camera with a viewmodel.