Hey devforum Im working on a camera mecahnic using springs, dot product, and some other math

Hey devforum,

I can’t seem to figure out how to do this. What I want to do is when the player looks left(the camera rotates left) I want to spring a slight tilt or rotation on the z axis.

So essentially I want to wait till the player moves their camera left or right upon doing that, spring rotate the camera on the zed axis based on which way they rotated and multiply the speed and intensity of the spring by how fast it was traveled.

currently I use this code below to check the last position of the LookVector and the old one comparing them with the dot product as well as seeing if they are a large enough in units to activate the spring. Here is the code;

local allowedRange, maxBlur = 10, 25

local function degreesToDot() return math.cos(math.rad(allowedRange)) end

local dot = prevLookVector:Dot(camera.CFrame.LookVector)
	if counter % dampener == 0 then --only run every so often

		local dot = prevLookVector:Dot(camera.CFrame.LookVector)

        --[[anything within 10 degrees of the previous one is not blur-worthy!
        also, 10 degrees will be ~0.98, the closer the dot is to 1, the closer
        the look vector is to the previous one; we want the dot product to be 
        higher than 0.98]]
		if dot >= degreesToDot() then--Pretty much standing still = 1 and moving is less than 1
			--below 1


	prevLookVector = camera.CFrame.LookVector
	counter = counter + 1

I did not write this code btw. got it here.