#Bug: Rotation overflow in `FpcRotationOverrideMessage`

1 messages · Page 1 of 1 (latest)

light fossil
#

FpcRotationOverrideMessage attempts to compress X and Y rotations into a single int by using Mathf.Lerp, but forgets to use Mathf.Repeat leading to rotations like 500° turning into 360° = 0° instead of expected 140°. This is how it can be fixed:

rotation.x = Mathf.Repeat(rotation.x + 180f, 360f) - 180f; // It is limited to [-90, 90], not [0, 180], so the repeat has to be offset to work correctly, hence +180
rotation.x *= -1f; // It is also inverted in FpcMouseLook, so we need to invert it back for quaternion math to work correctly with the rotation
rotation.y = Mathf.Repeat(rotation.y, 360f);

Attached is the screenshot of FpcRotationOverrideMessage method in question