Hi
I have a 3rd person follow-cam in my game with quite a lot of “step”.
mCamControl = new HoverController(camera, mLookAtObject, 180, 17, 15);
mCamControl.steps = 32;
mCamControl.wrapPanAngle = true;
It rotates OK for one revolution, but after that if i keep spinning my character, whenever a full +/-360 degrees is completed, the camera quickly rotates ~360 degrees the wrong way to meet the target position from the “other direction”.
I take it this shouldn’t happen when using wrapPanAngle == true?
Not unless the current angle differs from the desired one by more than +/-180 degrees anyways (in which case rotating in the opposite direction is the fastest way to get to the right position).
Adding this to HoverController.update() fixes it for me (the last “if” is added)
if (wrapPanAngle) {
if (_panAngle < 0)
panAngle = (_panAngle % 360) + 360;
else
panAngle = _panAngle % 360;
if (panAngle - _currentPanAngle < -180)
panAngle += 360;
else if (panAngle - _currentPanAngle > 180)
panAngle -= 360;
}
_currentTiltAngle += (_tiltAngle - _currentTiltAngle)/(steps + 1);
_currentPanAngle += (_panAngle - _currentPanAngle)/(steps + 1);
// added by me
if (wrapPanAngle) {
if (_currentPanAngle < 0)
{
_currentPanAngle = (_currentPanAngle % 360) + 360;
}
else
{
_currentPanAngle = _currentPanAngle % 360;
}
}
The fix is just something i came up with real quick, so that’s not the issue here. Just making sure this is an issue and not just something i have misunderstood about the HoverController?!?!