Mouse Scroll

May 17, 2009 at 1:00 AM

Hello.

I added a firstpersoncontrolledcamera3d in the game, you can make the camera closer or away with the scroll mouse?

Coordinator
May 17, 2009 at 1:13 AM

What you describe sounds like a 3rd person camera.

If you want to zoom in / out, then you can change the field of view of the camera (camera.Projection.FieldOfView).

UpdateState provides direct access to the mouse state (state.MouseState). You can also map PlayerInput controls to the mouse wheel (however, only analog controls, such as the triggers can be mapped to the wheel). This can be done with KeyboardMouseControlMapping.

So, for example:

	float wheelDelta = state.MouseState.ScrollWheelDelta;

	if (wheelDelta > 5) wheelDelta = 5;
	if (wheelDelta < -5) wheelDelta = -5;

	this.camera.Projection.FieldOfView *= 1.0f + wheelDelta * 0.1f;
May 17, 2009 at 5:35 PM

Perfect, tkx for awser