# FPS camera, euleranglesles and stuff. (solved)

So. I’ve been trying to make myself a script for the camera in a FPS game that i’m trying to make. To actually make it a little bit interesting, I’m planning on having a system in this game where the player can change their gravity (6 directions of gravity, think navigating around the inside of a cube). Anyways, the system that I’m trying to use with it just doesn’t seem to work with the system of camera movement that I’m using.

The main idea for the camera movement is to be using euler angles in a way. Something like

``````myRotation.y += Input.GetAxis("Mouse X") * sensitivityY * Time.deltaTime;
myRotation.x -= Input.GetAxis("Mouse Y") * sensitivityX * Time.deltaTime;
transform.eulerAngles = myRotation;
``````

Now, with the way that I want the gravity to change, I’m currently thinking of having 4 or 5 buttons, each of which will make the gravitatinal direction go forward/backward/left/right. when the gravity is changed, I’m trying to make the camera turn sideways and such to go with it. If I’m having my character constantly facing the default direction, my current system works fine, and the camera rotates to it’s side by 90 degrees. However, with the current script, the player’s sideways rotation is using eular angles, so I can’t actually use the player’s transform.right or anything like that… I’ve tried to simply make a variable and make the object’s rotation equal to that variable, but it keeps screwing up (i’m guessing it’s screwing up because I’m using EularAngles for the camera’s rotation in other parts).

``````//some of the current code i'm using to turn the camera on it's side (this is part of the earlier snippet of code)

Zvariable:float = 0;

if(Input.GetKeyDown(KeyCode.L))
{
Zvariable += 90;
}
if(Input.GetKeyDown(KeyCode.J))
{
Zvariable -= 90;
}

transform.eulerAngles.z += Zvariable
``````

Uhmmm i feel like my trying to explain the situation might have made it impossible to actually tell what I’m looking for. Rephrasing time.

-I manipulate a variable and set the euler angles to those values for a pretty standard FPS camera look
-I want to be able to press a button and rotate the camera onto it’s side by 90 degrees
-The current way I’m doing it works if i’m only facing “forward”, but it won’t change according to the direction that I’m looking
-For some reason using something like rotation.z = Zvariable doesn’t work
-any ideas on what do?

Well my writing sucks… thanks in advance for anyone who actually gets what I mean and may have a solution.

you propably want to look at this