Search Unity

rotation x axis space game problem, can only rotate 1 way

Discussion in 'Scripting' started by Zastrow89, Oct 21, 2012.

  1. Zastrow89

    Zastrow89

    Joined:
    May 1, 2010
    Posts:
    51
    i just starting out with building the basis of a space game with mouse controls and keyboard, i have my W as throttle and mouse for rotation, my problem is though that now i can only turn UP (moving my mouse down as intended) but i cannot get it to go abive 0 in my "yew" igt goes to minus perfectly fine, but i cannot get my space craft to "dive" :/ my code is as follow:

    Code (csharp):
    1.     public float yew = 0f;
    2.     public float yewMax = 0f;  
    3.  
    4. //yewing
    5.        if(engineOn == true){
    6.          yew += Input.GetAxis("Mouse Y") * 50f * Time.deltaTime;
    7.        }
    8.  
    9.        yew = Mathf.Max(Mathf.Min(yew,yewMax),(-45f));
    10.        transform.Rotate(yew*Time.deltaTime,0,0);
    11.  
    12.        if(yew > 0  Input.GetAxis("Mouse Y") == 0f){
    13.          yew-=Time.deltaTime * 10f;
    14.          yew = Mathf.Max(yew,0);
    15.        }
    16.  
    Any help would be apreaciated ^^ im still VERY new to unity and coding in general so be gentle hehe! Best regards Martin
     
  2. OrbitusII

    OrbitusII

    Joined:
    Jul 4, 2011
    Posts:
    175
    It might be best to simply utilize the keyboard to steer by getting input from some axes defined in editor/input or use the mouseLook script that may or may not be included by default with unity (I forget). I'll be sure to post my ship driver script so you can take a look at that.

    For using the mouse to steer: did you make sure to specify the positive AND negative inputs in the mouse y axis? If you only have one then that will definitely cause problems.
     
    Last edited: Oct 21, 2012