Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirstPersonController camera pan angle issue #506

Closed
lightsplasher opened this issue Apr 11, 2013 · 5 comments
Closed

FirstPersonController camera pan angle issue #506

lightsplasher opened this issue Apr 11, 2013 · 5 comments

Comments

@lightsplasher
Copy link

The FirstPersonController snaps the camera all the way around when the pan angle is set to less than -360 or greater than 360. A suggested correction to the update function:

public override function update():void
        {
            if (_tiltAngle != _currentTiltAngle || _panAngle != _currentPanAngle) {

                notifyUpdate();
                /*
                // Removed bw
                // Causes the camera to snap all the way around when panAngle < -360 || > 360
                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);


                //snap coords if angle differences are close
                if ((Math.abs(tiltAngle - _currentTiltAngle) < 0.01) && (Math.abs(_panAngle - _currentPanAngle) < 0.01)) {

                    // Added bw
                    // Reset panAngle to an equivalent angle within 360 degrees
                    if (_panAngle < 0)
                        panAngle = (_panAngle % 360) + 360;
                    else
                        panAngle = _panAngle % 360;
                    // End bw

                    _currentTiltAngle = _tiltAngle;
                    _currentPanAngle = _panAngle;
                }
@iY0Yi
Copy link

iY0Yi commented Apr 11, 2013

Neat!!!
This works perfectly.

@iY0Yi
Copy link

iY0Yi commented Apr 23, 2013

Sorry, this is not enough.
Pan a little (about 10-20 degrees) and stop pannning without releasing the mouse down,
then camera starts weird panning.

@lightsplasher
Copy link
Author

Nice catch! Try changing the addition to this:

                    // Added bw
                    // Reset panAngle to an equivalent angle within 360 degrees
                    if(Math.abs(_panAngle) > 360) {
                        if (_panAngle < 0)
                            panAngle = (_panAngle % 360) + 360;
                        else
                            panAngle = _panAngle % 360;
                    }
                    // End bw

@iY0Yi
Copy link

iY0Yi commented Apr 25, 2013

Thank you for fast replying.
But there is a buggy behavior yet.
After panning over 360 without releasing the mouse down,
And stay the mouse there, the weird panning starts again...
I will check the code by myself too. Thanks.

@rob-bateman
Copy link
Member

fixed in 68a8bdc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants