// Update is called once per frame void Update() { iPx = Input.acceleration.x; // if(Mathf.Abs(iPx)<2) accx = Mathf.Abs(iPx); if (Input.touchCount > 0) { touch = Input.touches [0]; } if (count > 150) { setCount(140); } else { setCount(getCount() + 1); } foreach (Transform t in transform) { // if(t.name == "caryell") { //t.renderer.enabled=false; cr = t.GetComponent <carRotate>(); health = cr.delay; if (cr.gameover) { audio.Stop(); // print ("health is : "+health); } } } /* * * // if (Input.touchCount == 1||Input.touchCount == 0) * { * touch = Input.touches [0]; * * * // if (Input.GetKey (KeyCode.L)||iPx>0.05f) * // if(Input.GetKey(KeyCode.K)) * if (Input.GetKey (KeyCode.L) || touch.position.x > Screen.width / 2) { * left = true; * right = false; * * * } else * // if (Input.GetKey (KeyCode.K)||iPx<-0.05f) * if (Input.GetKey (KeyCode.K) || touch.position.x < Screen.width / 2) { * // if(Input.GetKey(KeyCode.L)) * left = false; * right = true; * * * } else { * left = false; * right = false; * * } * * * } * /* * else { * left = false; * right = false; * * } * * * */ if (cr.gameover == false && cr.firepress == false) { if (Input.GetKey(KeyCode.RightArrow) || (touch.position.x > Screen.width / 2 && Input.touchCount > 0)) { left = true; right = false; audio.pitch -= 0.001f; } else if (Input.GetKey(KeyCode.LeftArrow) || (touch.position.x < Screen.width / 2 && Input.touchCount > 0)) { left = false; right = true; audio.pitch -= 0.001f; } else { left = false; right = false; if (audio.pitch < 2.0f + speed - 0.4f) { audio.pitch += 0.01f; } } } else { left = false; right = false; } if (fuel < 0) { xspeep = 0; } xspeep *= friction; transform.Translate(Vector3.right * -xspeep); }
// Update is called once per frame void Update () { iPx = Input.acceleration.x; // if(Mathf.Abs(iPx)<2) accx = Mathf.Abs (iPx); if (Input.touchCount >0) touch = Input.touches [0]; if (count > 150) { setCount(140); } else { setCount(getCount()+1); } foreach (Transform t in transform) { // if(t.name == "caryell") { //t.renderer.enabled=false; cr=t.GetComponent<carRotate>(); health=cr.delay; if(cr.gameover) { audio.Stop(); // print ("health is : "+health); } } } /* // if (Input.touchCount == 1||Input.touchCount == 0) { touch = Input.touches [0]; // if (Input.GetKey (KeyCode.L)||iPx>0.05f) // if(Input.GetKey(KeyCode.K)) if (Input.GetKey (KeyCode.L) || touch.position.x > Screen.width / 2) { left = true; right = false; } else // if (Input.GetKey (KeyCode.K)||iPx<-0.05f) if (Input.GetKey (KeyCode.K) || touch.position.x < Screen.width / 2) { // if(Input.GetKey(KeyCode.L)) left = false; right = true; } else { left = false; right = false; } } /* else { left = false; right = false; } */ if (cr.gameover == false&&cr.firepress==false) { if (Input.GetKey (KeyCode.RightArrow) || (touch.position.x > Screen.width / 2 && Input.touchCount > 0)) { left = true; right = false; audio.pitch-=0.001f; } else if (Input.GetKey (KeyCode.LeftArrow) || (touch.position.x < Screen.width / 2 && Input.touchCount > 0)) { left = false; right = true; audio.pitch-=0.001f; } else { left = false; right = false; if(audio.pitch<2.0f+speed-0.4f) audio.pitch+=0.01f; } } else { left = false; right = false; } if(fuel < 0){ xspeep = 0; } xspeep *= friction; transform.Translate(Vector3.right * -xspeep); }