- Home /
weapon animation question
How can I associate animations to weapons? I made animations like switching weapon and bobbing weapon, but I can not associate the weapon switching animation to the key 2, or the bobbing animation to the ASD keys. Could someone tell me how could I do that ?
como posso criar associar animações em armas por exemplo eu fiz varias animaçoes a arma a trocar e a arma a mexer mas não sei associar a animação de trocar de arma a tecla 2 e a arma a mexer ás teclas a s d, someone could tell me how i do that?
How can I create animations associated weapons, for example I made many animations to change the weapon and the weapon to move but I can not associate the animation to change the key weapon and the weapon 2 ASD keys to move, Could someone tell me how i do that ?
@tugaf94, editei sua questão para ficar com o texto em inglês em primeiro lugar - isso facilita que as pessoas achem e respondam sua questão.
Aldonaletto is telling tugaf94 that he edited the question to include an english translation, so that those of us who don't speak Portuguese can understand it and help with the problem! (I don't understand Portuguese, but Romantic languages are all basically the same so I could guess what I didn't know)
As for the actual question, that requires a few different things in order to work the way @tugaf94 wants it to. For starters, you need to have a weapon-switching system already implemented- do you have one of those? The bobbing animation isn't too hard, just put it in with your movement script (blend it in by (currentSpeed/maxSpeed)). Have you imported all the animations properly? $$anonymous$$ake sure your bob animation is set to 'Loop', so that it won't just finish on you.
Answer by benjimazza · Oct 23, 2011 at 09:33 PM
So all you want is a Weapon Switching script ??? if so then this should do
function Start()
{ SwitchWeapon(0); }
function Update () { if(Input.GetKeyDown("1"))
{
SwitchWeapon (0);
}
else if(Input.GetKeyDown("2"))
{
SwitchWeapon (1);
}
else if(Input.GetKeyDown("3"))
{
SwitchWeapon (2);
}
}
function SwitchWeapon(index : int)
{
for( var i = 0; i<transform.childCount; i ++)
{
if(i == index)
{
transform.GetChild(i).gameObject.SetActiveRecursively(true);
}
else transform.GetChild(i).gameObject.SetActiveRecursively(false);
}
}
yes but with animation when i swicth weapon start an animation