- Home /
Animation not playing completely
I am having the problem that none of my animations (done in blender) plays all the way though. for most, that's not even an issue, though my attack animation looks just odd without playing completely.
My current script for choosing animations (inside my AnimationChooser.cs file) looks like this:
void Update ()
{
Player pstats = Player.GetComponent<Player>();
float running = Input.GetAxis ("Vertical");
float jumping = Input.GetAxis ("Jump");
float dashing = Input.GetAxis ("Dash");
float hitting = 0.0f; //for being hit
if (pstats.Hitanim)
{
hitting = 1.0f;
}
if (!pstats.Hitanim)
{
hitting = 0.0f;
}
if (Input.GetKeyDown ("a") && pstats.SlashUsable)
{
pstats.SlashLeft(); //basicly just starts the attack-script
}
if (Input.GetKeyDown ("d") && pstats.SlashUsable)
{
pstats.SlashRight(); //attack-script again
}
if (!pstats.SlashUsable)
{
dashing = 0.0f;
}
anim.SetFloat ("Speed", running*running);
anim.SetFloat ("Jumping", jumping*jumping);
anim.SetFloat ("Dashing", dashing*dashing);
anim.SetFloat ("Hitting", hitting*hitting);
}
The "Dash" is the one I need to play all the way through. On pressing the proper keys, it only plays around half-way. if I hold the key down, it plays half way once and then fully once, though that's not really the intended way.
I heared of having to start at frame 1 in blender (currently I go from frame 0 to 24), though when I tried to reimport my animation it went completely crazy (completely deformed the character), even though I only moved keyframes around.
I also heared about wrap-modes, but in all honesty, I am new to Unity and don't really know how and where I have to implement those.
Is there any way I can edit the code to have the animation play once, all the way through on one button press? (the difference between SlashLeft and SlashRight is just the characters rotation, the animation is the same)
Any help is highly appreciated.
Answer by meat5000 · Jun 28, 2014 at 10:57 AM
In Animator Window, click the transition from the attack animation and change Exit Time from 0.85 to 1.0
that worked, thanks! Though I noticed another odd thing. Whenever I use the attack, the character is lifted in the air slightly, like as if the animation was making him float above the ground for the first half of the attack. I have no idea why.
In Import settings for the model, In Animation tab, bake Y Position.
Well, I went to the Import settings - Animaion tab, and saw that "Root transform position (Y)" and checked "Bake into position", that didn't do anything. I tried both settings I have in the drop down menu and tried an off-set also, didn't change a thing.
Did you make sure to select the correct animation from the list before doing this? :)
of course, I made sure to do it on my attack-animation. It's the top of the list even. And yes, I also clicked "Apply" ^^
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Programmatically created AnimationClip will not loop 2 Answers
Clamping an animation does not work. Help! 0 Answers
Distribute terrain in zones 3 Answers
How to avoid animation from resetting after its completion? 1 Answer