Camera does not update in First Person when it is far away from World Origin

Apparently, I found out this very strange bug. This bug requires 2 extreme criteria:

  • Very high framerate (500+ FPS)
  • The camera is located ~4090 studs above the origin (0,0,0).

Which in my game, both criterias are possible.

In my game, player plays in a relatively high area from the origin (around (0,4500,0)) because that is where the maps were placed at. When player fires their weapon, there is a camera recoil, which is essentially cam.CFrame *= CFrame.Angles(x,y,z).

Since The Camera Recoil updates every frame, so the XYZ values are multiplied to (dt * 60) in order to have it synced in different frame-rate.

Let’s take the X axis as example. In each frame, the camera will be multiplied ~0.1 to the X value.
cam.CFrame *= CFrame.Angles(0.1 * (dt * 60),0,0) -- in each 60 FPS frame.

However, on very high framerate, e.g: 500, where dt is (1/500) = 0.002. When the X value (0.1) is multiplied to 0.002, the camera will need to update 0.0002 in each frame.
Here comes the problem:

In this video, this code is being ran. The number represents the Y axis of the camera.

game:GetService("RunService"):BindToRenderStep("test", Enum.RenderPriority.First.Value, function(dt)
      workspace.CurrentCamera.CFrame *= CFrame.Angles(0.001 * (dt * 60),0,0)
end)

And strangely, the camera does not update in First Person, only in third person. But when the camera gets to a lower level, it works fine.

It is just weird to see how the camera updates is relative to the camera’s world position. Is there a fix to this?

2 Likes

might be similar to floating point issues since the cframe value can take up the same amount of memory with larger numbers by lowering precision

maybe store the angle separately from the cframe and increment that each frame before setting the cframe