Hi,
I’m trying to switch weapons with animations made inside unity. This is the code to change between guns:
function cambiaDeArma(sel : int){
armaActual.animation.Play("baja_anim");
yield WaitForSeconds(1.15);
for(var a : int = 0; a < armas.Length; a++){
if (a!=sel)
armas[a].SetActive(false);
}
armaActual=armas[sel];
armaActual.SetActive(true);
armaActual.GetComponent(AI_ARMA).paraDisparo();
armaActual.animation.Play("sube_anim");
}
The problem is that the first gun plays the animation of hide and show the gun fine. But if i have the first gun and change to the second one, works fine except when the gun gets the end of the up animation. it jumps suddenly to an intermediate position instead stay pointing forward, wich is the last frame of the animation. if i change again to the first one. it reaches the end of the up animation and stays there.
Duplicating the first gun to ensure that the problem isnt in the animation gives the same error. Only works with the first gun.
Could you guys take a look at the code? I cant see were the problem is.
OH! and sorry for the code. I put the variables ins Spanish. armaActual is the current gun!
Thanks!