Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 20 May 2011
Offline Last Active Jan 31 2013 03:04 AM

Topics I've Started

Third Person Camera Tweaking rotation curve

30 January 2013 - 05:13 AM


I'm currently in the process of tweaking our camera rotation for PC with the mouse. But I'm kind of stuck on getting a nice speed and acceleration to it that feels natural for the mouse. Got it pretty much nailed down the gamepad, a linear curve works pretty well for the camera rotation on the gamepad.

My question is if anybody fiddled around with this before that could help me out and might help me speed up my tweaking process.

We have an ad-hoc solution so you can attach an input controller whenever so we can support both keyboard/mouse and gamepad during a game and these can be used interchangeably. To give you a feel of how the rotation is done right now I'll provide a snippet of code:
namespace Input
    class MouseController : InputController
        MouseState myLastState;
        const float MouseSensetivity = 0.5f;

        public MouseController()
            myLastState = Mouse.GetState();

        public InputState GetState()
            MouseState mouse = Mouse.GetState();
            InputState state = new InputState();
            state.cameraRotation.X = ((float)mouse.X - myLastState.X) * MouseSensetivity;
            state.cameraRotation.Y = ((float)mouse.Y - myLastState.Y) * MouseSensetivity;

            /* ...A lot of more input code... */
            /* ...Not concerning rotation...  */

            Vector2 screenCenterPosition = new Vector2(Core.Instance.myDefaultViewPort.Width / 2, Core.Instance.myDefaultViewPort.Height / 2);
            if (Root.Instance.myGFXManager.IsFullScreen == false)
                screenCenterPosition.X = Root.Instance.myWindow.ClientBounds.Center.X;
                screenCenterPosition.Y = Root.Instance.myWindow.ClientBounds.Center.Y;
            Mouse.SetPosition((int)screenCenterPosition.X, (int)screenCenterPosition.Y);
            myLastState = Mouse.GetState();
            return state;
I've tried a lot of several modifications to the state.cameraRotation vector but haven't really found anything that feels nice. or even work at all.

Thanks on before hand!