- Home /
Switch weapon animation jumps to unknown frame
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!
Answer by Danirey · May 25, 2013 at 04:35 PM
SOLVED!!
I dont know why, but this happend When any of the gun prefabs are disabled. before start the game. I cant explain more than that.... ;)
Your answer
Follow this Question
Related Questions
Making weapons animations for first person shooter 2 Answers
How to do something if two keys are pressed at the same time in a specific order? 1 Answer
Best Frame Rate to Animate with for pc game? 0 Answers
Al Robot Animation Problem 0 Answers
Workflow for animating FPS characters/items in Blender in a way that can be exported to Unity 0 Answers