Applying spring to camera orientation causes it to jump from 2pi to -2pi?

Hey guys. I’m trying to attach this critically damped spring to my camera on one axis (yaw), and it looks pretty good. The problem arises when the camera orientation gets close to 2pi (360 degrees), and when it passes that point the orientation jumps to -2pi. I’m not reporting this as an issue, I understand why it happens and that it’s supposed to happen. The problem is that my spring will, instead of seamlessly jumping from 2pi to -2pi, go to pi, then 0, then -pi, and then -2pi. Obviously this is unusable.

To get the orientation of the camera, I’m just using :ToEulerAnglesYXZ() and setting the target of a spring to the yaw and the orientation of the camera to the spring position. Remember, I’m only applying this to one axis. I’ve had this problem for a while but always just scrapped the idea so that I wouldn’t have to address this issue, so I figured this time I’d ask for some help.

I get why it happens, but I’m curious if anyone had any suggestions for preventing this from happening.

Thanks

1 Like