Hi,
I want my character to "Power Up".
Now, when you press the power up button, it plays the first animation, the loops the appropriate animation. Only problem is, the animation does not stop playing.
I want to let the loop animation play for as long as you press the button down, and when the button is released, it must stop the animation. Any ideas?
Ps. I got the script from another question in this forum.
var PowerUp : String = "PowerUp";
var PowerUpLoop : String = "PowerUpLoop";
function COPowerUp() {
var state : AnimationState = animation[PowerUp];
state.wrapMode = WrapMode.ClampForever;
state.speed = 1.0;
animation.Play(PowerUp);
yield new WaitForSeconds(state.length);
animation.Play(PowerUpLoop);
inTransition = false;
}
function Update () {
var horizontal = Input.GetAxis("Horizontal");
var vertical = Input.GetAxis("Vertical");
if (Input.GetButtonDown("Power Up")) {
StartCoroutine(COPowerUp());
}
if (Input.GetButtonUp("Power Up")){
StopCoroutine(COPowerUp());
}
}