- Home /
My Animation Loops 3/4 of the way through
Im trying to make my Walk animation Loop correctly.
My animation correctly works in preview but when I do it in the game tab, it goes 3/4 of the way through the cycle then loops instead of waiting for the animation to completely finish then loop. Here's my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class player : MonoBehaviour {
public Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
if (Input.GetKey ("w")) {
anim.Play("walk01");
}
if(Input.GetKeyDown ("space")){
anim.Play("jump01");
}
}
}
Here's where my animation loops
As you can see it doesn't reach the end of the animation clip but loops at the 3/4 mark.
How do I fix it? thx for any help
Answer by $$anonymous$$ · Dec 21, 2017 at 08:10 PM
Is the transition from the animator state "walk01" to "idle01" set to automatically trigger after some given time? Because in this case the line "anim.Play("walk01");" would reset the animation to the start afterwards. It looks like that because in your movie the idle animation seems to be playing for a frame.
How would you check this? thanks for the help though, if this is what's is happening how do you fix it?
Actually IT WAS THIS, it overlapped the walk animation thank you so much :D
Answer by Phoenix3666 · Dec 21, 2017 at 07:06 PM
I tried you first two suggestions, I haven't made a transition from idle01 to jump01 because then the idle animation automatically goes to jump randomly when I don't want it to, I realize that maybe I didnt explain the problem well enough, heres a 10 second video https://goo.gl/8E1gyQ In the video it correctly plays the animation, but halfway through it loops instead of waiting till the animation finishes then looping, thanks for any help, thanks for the suggestions @paincide
It goes right back to idle. Can you post your scene file and share to me? Let me try it in my computer
I dont know if this will work sharing, but hopefully it will heres the link https://goo.gl/XtyCpA @PaincideStudio
Answer by Paincide · Dec 20, 2017 at 06:28 AM
There are some ways to try
Check if you haven't checked has exit time
Try using bool from Parameters.
Why is there only 'walk01-> killer01' and 'jump01->killer01'? Maybe that can cause a problem.
You can use animations and use animation.playqueued.
Your answer
Follow this Question
Related Questions
how to keep track of Lean Tween function? 0 Answers
Why when creating new animator controller for the character the character is not walking right ? 0 Answers
How can i check if animation has finished playing if the object have no animator attached ? 1 Answer
loop animation through controller for period of time? C# 1 Answer
UNITY 2D: How to make a level selection menu (like the video in details)? 1 Answer