- Home /
Flying space game rotate X axis problem
i just starting out with building hte 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:
public float yew = 0f;
public float yewMax = 0f;
//yewing
if(engineOn == true){
yew += Input.GetAxis("Mouse Y") * 50f * Time.deltaTime;
}
yew = Mathf.Max(Mathf.Min(yew,yewMax),(-45f));
transform.Rotate(yew*Time.deltaTime,0,0);
if(yew > 0 && Input.GetAxis("Mouse Y") == 0f){
yew-=Time.deltaTime * 10f;
yew = Mathf.Max(yew,0);
}
Any help would be apreaciated ^^ im still VERY new to unity and coding in general so be gentle hehe! Best regards Martin
Answer by tavoevoe · Oct 21, 2012 at 07:44 AM
I'm almost positive this line's your problem:
yew = Mathf.Max(Mathf.Min(yew,yewMax),(-45f));
What your saying is, lock yew to: -45 < yew < yewMax (set to 0).
Make yewMax more than zero, or yew won't go above zero.
Ahhhh DOH! how could i not have seen that xD thank you so much! guess tiredness can kill anyone XD thank you!