I’m trying to simulate a helicopter pitch/yaw/roll but I’ve run into a problem i cant find a solution for:

Demo:

http://tristanjc.com/unity/newweb.html

When you get into the air, the pitch and roll work fine from start rotation, but if you rotate yourself to face the camera (Z and C) and press pitch forward it tilts to the left and right instead. Aswell as other rotation bugs when rotating left or right.

The code for these bits are:

```
// ===== Yaw ======= //
if(Input.GetKey(KeyCode.Z)){
if(engineReady){
heli.transform.rotation = new Quaternion(heli.transform.rotation.x, heli.transform.rotation.y + 0.01f, heli.transform.rotation.z, heli.transform.rotation.w);
}
}
if(Input.GetKey(KeyCode.C)){
if(engineReady){
heli.transform.rotation = new Quaternion(heli.transform.rotation.x, heli.transform.rotation.y - 0.01f, heli.transform.rotation.z, heli.transform.rotation.w);
}
}
```

– Roll

```
float temproll = roll / 1.66666f;
temproll = (temproll - 30.0f) / 100.0f;
rollDegrees = temproll;
helirollSpeed = Mathf.Abs((temproll * 100.0f));
heli.transform.rotation = new Quaternion(heli.transform.rotation.x, heli.transform.rotation.y, rollDegrees, heli.transform.rotation.w);
```

– pitch

```
float tempPitch = pitch / 1.66666f;
tempPitch = (tempPitch - 30.0f) / 100.0f;
pitchDegrees = tempPitch;
heliSpeed = Mathf.Abs((tempPitch * 100.0f));
heli.transform.rotation = new Quaternion(pitchDegrees, heli.transform.rotation.y, heli.transform.rotation.z, heli.transform.rotation.w);
```

How would I keep rotation locked for each one.