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.