I have been working on a top down camera script and when you move the mouse the camera sorta turns towards the mouse. I think its pretty nice, except there is one small problem.
The camera seems to lag behind the player movement so when you are moving the camera will slowly get farther behind you (depending where your mouse is on the screen).
Heres a gif of the example, see how the mouse slowly moves away from the player, that means the camera is moving away from the player.
https://gyazo.com/1920c5a5fad1908737d15ce4bbd103dd
Heres the math portion of the script, its the part that is causing the problem. Ive managed to narrow it down to one line though.
Camera.CFrame = CFrame.new(Character.HumanoidRootPart.CFrame.Position + Vector3.new(0, CameraHeight, CameraHeight/5), CFrame.new(Character.HumanoidRootPart.CFrame.Position).Position + Vector3.new(Mouse.Hit.X/(CameraMovement * 2), 0, Mouse.Hit.Z/CameraMovement))
Theres the math for the camera script and the movement
But heres the part of the script that is causing problems because when I comment this part out it works fine. Its basically the mouse movement part that is causing problems.
Vector3.new(Mouse.Hit.X/(CameraMovement * 2), 0, Mouse.Hit.Z/CameraMovement)
Could anyone help me? Thank you for your time :)