You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
863 B
32 lines
863 B
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); |
|
} |
|
|
|
|
|
|
|
|