SmoothDamp and rounding problem


I’m using Vector3.SmoothDamp to make my camera follow my player smoothly, it works perfectly, but i’m trying to round my camera’s position so that it snaps to the pixels.

My code works fine in editor but when running the build with a much higher FPS, the cam is super jerky and fast.

There must be something i’m doing wrong, is anyone able to explain what is going on?

This is running in Update, why is it framerate dependent?

Vector3 smoothedCam = Vector3.SmoothDamp(cam.transform.position, player.transform.position, ref velocity, camSpeed);

            cam.transform.position = new Vector3(Mathf.Round(smoothedCam.x * pixelsPerUnits) / pixelsPerUnits, Mathf.Round(smoothedCam.y * pixelsPerUnits) / pixelsPerUnits, cam.transform.position.z);

Solved it by using SmoothDamp on a new Vector3, and instead made the camera follow this vector, then rounded the camera’s position.

Hi, did you solve it? I have a similar problem with the camera and my FPS

Turned nice rounding camera after smooth damp, help me a bit but not fixed yet