Reputation: 1152
So I am pretty new to XNA, but I've figured out how to create a camera object and control it. I want to have some more intuitive controls for my camera, because when the cursor hit's the edge of the screen with the following code, the rotation stops. And that's a little unintuitive.
I want to be able to reset the cursor's position to the middle of the screen, how can I do this?
MouseState mouseState = Mouse.GetState();
yaw -= (mouseState.X - oldx) / 600.0f;
pitch -= (mouseState.Y - oldy) / 600.0f;
oldx = mouseState.X;
oldy = mouseState.Y;
Upvotes: 2
Views: 3577
Reputation: 22123
To set the mouse position to the middle of the screen:
Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
You can see an example of this at Riemers XNA Tutorials.
Upvotes: 5