var speed = 5.0; var limitY = -44.0; function Update () { if (this.gameObject.transform.position.y <= 130 && this.gameObject.transform.position.y >= limitY) { if (Input.GetKey(KeyCode.UpArrow)) { transform.Translate(0, speed * Time.deltaTime, 0); } if (this.gameObject.transform.position.y >= 130) { this.gameObject.transform.position.y = 130; } } if (this.gameObject.transform.position.y <= 130 && this.gameObject.transform.position.y >= limitY) { if (Input.GetKey(KeyCode.DownArrow)) { transform.Translate(0, -speed * Time.deltaTime, 0); } if (this.gameObject.transform.position.y <= limitY) { this.gameObject.transform.position.y = limitY; } } //Debug.Log("aa"+this.gameObject.transform.position.y); }