Hi there!
Hope all is well... I'm having problems playing sound clips, and also problems with animations.
I have 2 sound clips I want to play, first, "PowerUpStart" when the "Power Up" animation is playing, and then "PowerLoop" sound when the "PowerUpLoop" animation is playing. I tried everything but cannot get it to work, and nothing regarding the sound is in the below script.
Second, when my "PowerUpLoop" animation plays, I dont want the player to be able to move around until the the "Power Up" button is released, any ideas?
var PowerUp : String = "PowerUp"; var PowerUpLoop : String = "PowerUpLoop"; var emit : boolean; var enabled : boolean;
private var inTransition : boolean = false; private var isPowerUpLoop : boolean = false; particleEmitter.emit = false; renderer.enabled = false; light.enabled = false;
function COPowerUp() { inTransition = true; isPowerUpLoop = true; var state : AnimationState = animation[PowerUp]; state.wrapMode = WrapMode.Once; state.speed = 1.0; animation.Play(PowerUp); yield new WaitForSeconds(state.length); (animation.Play(PowerUpLoop)); particleEmitter.emit = true; renderer.enabled = true; yield new WaitForSeconds(.1); light.enabled = true; }
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");
particleEmitter.emit = false;
light.enabled = false;
animation.CrossFade("idle");
inTransition = false;
isPowerUpLoop = false;
}
}