First person camera weighted random variation

GREETINGS TO ALL! :smiley:

This is connect to the runservice.RenderStepped

It changes the angle of the mouse randomly for a First person game.

The issue is if left for too long without moving your camera, the mouse goes too far away from the original position.

Can anyone think of an a way of weighting the randomness towards the last inputted mouse location depending on how far away it is?

I have no clue how one would go about storing the current angle its at along with weighting func1 and func2 towards that last inputted value.

I will also add a scale value so the futher away it is from the last inputted value, the more* weighted it is, but If given a way to get the angle, I can do that.

func1 = lerp(func1, math.cos(tick() * 0.5 * math.random(10, 15)) * (math.random(5, 20) / 200) * deltaTime, 0.05 * deltaTime)
func2 = lerp(func2, math.cos(tick() * 0.5 * math.random(5, 10)) * (math.random(2, 10) / 200) * deltaTime, 0.05 * deltaTime)

local NewCFto = camera.CFrame

-- Random Variation
NewCFto = NewCFto * CFrame.fromEulerAnglesXYZ(math.rad(func1* 4), math.rad(func2* 4), math.rad(func2 * 10))

Thanks for your help! :sweat_smile: