- Home /
Problem with multiple animation Controlle Script
Hello guys,
I have problem when playing animatons when I press a joystick button, only the two first animations work, but the 2 last are not working
if(Input.GetButtonDown("Fire1")){
// Instantiate(AttackEffect, transform.position, transform.rotation);
//animation.Play("gogo_fire");
// audio.PlayOneShot(AttackSound);
_animation.CrossFade(Sword_Anim.name);
walkSpeed = 1.0;
trotSpeed = 1.0;
}
if(Input.GetButtonUp("Fire1")){
walkSpeed = 14.0;
trotSpeed = 16.0;
}
if(Input.GetButtonDown("Fire2")){
// Instantiate(AttackEffect, transform.position, transform.rotation);
//animation.Play("gogo_fire");
// audio.PlayOneShot(AttackSound);
_animation.CrossFade(Sword_Anim2.name);
}
if(Input.GetButtonDown("Fire3")){
// Instantiate(AttackEffect, transform.position, transform.rotation);
//animation.Play("gogo_fire");
// audio.PlayOneShot(AttackSound);
_animation.CrossFade(Sword_Anim3.name);
//animation.Blend("gogo_sword2");
}
if(Input.GetButtonDown("FireJoy")){
// Instantiate(AttackEffect, transform.position, transform.rotation);
//animation.Play("gogo_fire");
// audio.PlayOneShot(AttackSound);
_animation.CrossFade(Sword_Anim4.name);
}
Please help :'(
Please format your code properly: Edit your question, mark everything that is code and hit the 101010 button next to the paperclip (attachment) button. =)
thank you so much guys, its the first time I post here :)
Answer by GameVortex · Dec 07, 2013 at 08:43 AM
Okay, so what you are saying is that only "Fire1" and "Fire2" works, which plays Sword_Anim and Sword_Anim2 right?
There are a lot of things that can make this go wrong, so here is a little checklist:
1: Is the buttons "Fire3" and "FireJoy" hooked up to a joystick button and do they work at all? Go into: Edit - Project Settings - Input. And make sure the buttons are set up correctly. If they are then put a debug log in the script to print out if they are actually responding when pressing a button.
2: Are the animations Sword_Anim3 and Sword_Anim4 referenced in the editor inspector of this component? Go into the editor inspector of this gameobject and check if those two animations are referenced in the same way the two first animations are.
3: Also are the animations referenced in the Animation component itself? If the animation component does not have them it can not play them at all. Go into the inspector of the animation component and make sure they are referenced in the same way as the two first animations.
4: Does Sword_Anim3 and Sword_Anim4 actually have any keyframes and animation in them? Maybe they are actually playing but they have nothing to do in their animation. Check the import settings to make sure everything is alright. If they are made in unity, maybe they did not get saved properly?
5: If you are getting any errors or warnings or messages in the console, then include them with your question.
Hello sir, you are right, but I checked every thing you said but all working good, because the animations working only on
if(Input.GetButton("Fire3"))
and not on
if(Input.GetButtonDown("Fire3"))
Weired!!!
I don't have much more ideas of what could be wrong. $$anonymous$$aybe you could either post the entire script you are using, or if you want you could zip up your project and add it to your question and I can take a look.
Your answer
Follow this Question
Related Questions
Network view not attached 0 Answers
Player moves faster when fps is higher? 1 Answer
Gate Question 1 Answer
Cant build game 3 Answers