var shake:float = 5; var setShake:float; var shakeSwitch:boolean = false; function Start() { setShake=shake; } function OnGUI() { if (GUILayout.Button ("Shake")) { shake=setShake; shakeSwitch=true; } } function Update() { if(shakeSwitch==true){ transform.position.x = Random.Range(0,shake * 2) -shake; transform.position.y = Random.Range(0,shake * 1) -shake; shake = shake/1.05; if (shake < 0.05){ shake = 0; shakeSwitch=false; } } }
0 ♥:
張貼留言