# Player Rotation Problem

Hi, I am creating a FPS and have run into a problem with the rotaion of the palyer. If the user pushes the mouse up or down the player will flip over. I have experimented with the .getRotation() method but have not had any luck. If anyone knows a way or has any ideas on how to solve this issue it would be greatly appreciated.

Use lookAt(vec,Vector3f.UNIT_Y);

to get the vec:

vec = camera.getDirection().clone();

vec.y = 0;

And that should make him look around, but not up and downâ€¦

that made my guy look at the middle of the map and i couldnt move him with the mouse

Oh!

Sorry!

vec.y = camera.getLocation().y;

Then it works!

I think he wants to constrain the y rotation to pi, not 0. So he canâ€™t look at things upside down.

@kidneytrader: Yes, I am trying to make it so that i cant look at things upside down. That is exactly what I had thought, but whenever you reach that certain point it tilts your camera angle to a awkward poistion.

[java]if (cam.getDirection().getY() > camYLimit)

cam.lookAtDirection(cam.getDirection().setY(camYLimit), Vector3f.UNIT_Y);

else if (cam.getDirection().getY() < -camYLimit)

cam.lookAtDirection(cam.getDirection().setY(-camYLimit), Vector3f.UNIT_Y);[/java]

Set camYLimit to .9f or greater.

There appears some weird smoothing effect I donâ€™t understand. It takes time for the camera to look at the specified direction so you can go past it and it doesnâ€™t look very nice. Maybe someone can explain how to constrain the view better?

it works, but it makes me look at the ground when i reach that height

I donâ€™t understand what you mean. For me it makes you look less at the ground since you should already be looking more at the ground. The problem is it doesnâ€™t do it instantly so it looks very unprofessional.

what did you set camYLimit to? was it like 0.74?

No, I set it to .9f or greater. The problem youâ€™re saying disappears but this is still not the right way to do it. lookAt does exactly the same thing.

private static final float MIN_ANGLE_X = -85FastMath.DEG_TO_RAD;

private static final float MAX_ANGLE_X = 75