I have an aeroplane object that rotates using Input.GetAxis input. It's limited to a 100degree range of motion on both z and y axes:
if (transform.eulerAngles.z < 50 || transform.eulerAngles.z > 310) {
transform.Rotate(0f, Input.GetAxis("Horizontal"), -Input.GetAxis("Horizontal"));
}
if (transform.eulerAngles.y < 50 || transform.eulerAngles.y > 310) {
transform.Rotate(Input.GetAxis("Vertical"), 0f, 0f);
}
The plane is propelled forward by pressing a button, and forward is the direction the plane is facing:
transform.position += transform.forward * Time.deltaTime * speed;
This doesn't behave as I'd like. When the plane reaches the limit of the rotation (e.g. transform.eulerAngles.z == 50), the plane no longer moves in an 'arc', as in, forward is not a straight line. When it reaches the limit, the plane just moves in a straight line. I'd like it to continue to arc, just not beyond the rotation limit. I hope that makes sense? Does anyone have any tips on how I can achieve this?