Im trying to get to alternate power bars to work one after another once you have pressed space bar to select your power bar. But i cant get the other to start and then stop again once the button is down. heres the code so far:
var fullWidth : float = 256;
private var thePower : float;
var increasing : boolean = false;
var shooting : boolean = false;
var barSpeed : float = 25;
var ball : Rigidbody;
var spawnPos : Transform;
var shotForce : float = 5;
function Start(){
guiTexture.pixelInset.width = 0;
increasing=true;
}
function Update () {
if(!shooting Input.GetButtonDown(“Jump”)){
increasing=false;
}
if(!shooting Input.GetButtonUp(“Jump”)){
increasing = false;
Shoot(thePower);
}
if(!shooting Input.GetButtonDown(“Jump”)){
increasing=true;
}
if(increasing){
thePower += Time.deltaTime * barSpeed;
thePower = Mathf.PingPong(Time.time, 1) * fullWidth;
guiTexture.pixelInset.width = thePower;
}
}
function Shoot(power : float){
shooting = true;
var pFab : Rigidbody = Instantiate(ball, spawnPos.position, spawnPos.rotation);
var fwd : Vector3 = spawnPos.forward;
pFab.AddForce(fwd * power * shotForce);
Destroy(pFab.gameObject, 4);
yield WaitForSeconds(3);
guiTexture.pixelInset.width = 0;
thePower = 0;
shooting = false;
}