今回のワークショップで作ったスクリプトその3
#pragma strict
var mySpeed : Vector3;
var maxHeight : int;
var currentHeight : int;
function Start(){
yield WaitForSeconds (5);//いきなりスタートさせると子ども困るので5秒待たせてる.カウントダウンの絵とか入れたかったなぁ
SpeedCheck(true);//SpeedCheckをtrueにすると動きます
}
function Update() {
currentHeight = transform.position.y;//いまの高さ出します
if (currentHeight > maxHeight){//maxheightより高ければ
transform.position.y = maxHeight;//maxheightの高さで固定ね
}
transform.Translate(mySpeed);//移動〜
}
function SpeedCheck(sp : boolean){//falseが来たら
if(sp == false){
mySpeed = Vector3(0,0,0);//飛行機停止
GetComponent(myAlt).fallOff();//爆発のスクリプト実行
yield WaitForSeconds (5);//残念でした画面の前に5秒待ちます
Application.LoadLevel ("bad");//シーンbad読み込み
}if(sp == true){
mySpeed = Vector3(2,0,0);//普段は常に2移動
}
}