The mouse doesn't teleport though. When there's a lag spike, the mouse moves much more in one frame because that frame is longer. Something in the code is overcompensating for that and making it jump. The cursor is snapped back to center every frame, so it never reaches an edge. If you move the camera around when there's no lag spike, there will be no jumping around. There is no teleporting of the muse cursor. Some games have that, this one doesn't.