Some animations not looping how I want

midnightcat123
Joined:Feb 20, 2018
Posts:2
Hello
I have a 2d player with 8-direction turning (I didn’t make the 8-direction turning script myself, but I made changes to it). In the script it tells which direction to go and which animation to play. Then when I stop pressing a key it goes to the one frame idle animation associated with it when the anim_over condition is on. All the animations have Has Exit Time turned off, also. My problem is that walking right, left, and up aren’t looping while I walk as the other 5 directions are and I’ve been unable to find a solution.

Video of What I mean:

link text

Full code for this:

using UnityEngine;
using System.Collections;
 
public class playerController : MonoBehaviour
{
    Animator anim;
    public float speed = 1f;
    private Vector2 movement;
 
 
    // Use this for initialization
    void Start()
    {
        anim = GetComponent<Animator>();
    }
 
    // Update is called once per frame
    void FixedUpdate()
    {
        float inputX = Input.GetAxisRaw("Horizontal");
        float inputY = Input.GetAxisRaw("Vertical");
        movement = new Vector2(inputX, inputY);
 
        //Diagonals
       
        if (inputX != 0 && inputY != 0)
        {
            if (movement.y == 1 && movement.x == -1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_up_left"))
            {
                anim.SetTrigger("move_up_left");
            }
 
            if (movement.y == 1 && movement.x == 1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_up_right"))
            {
                anim.SetTrigger("move_up_right");
            }
 
            if (movement.y == -1 && movement.x == -1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_down_left"))
            {
                anim.SetTrigger("move_down_left");
            }
 
            if (movement.y == -1 && movement.x == 1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_down_right"))
            {
                anim.SetTrigger("move_down_right");
            }
        }
 
        else if (inputX != 0 || inputY != 0)                                                                 //These are the animations that arent looping...
        {
 
            //left/right/up/down
            if (movement.x == -1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_left"))
            {
                anim.SetTrigger("move_left");                                                                                                  
            }
 
            if (movement.x == 1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_right"))
            {
                anim.SetTrigger("move_right");
            }
 
 
            if (movement.y == 1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_up"))
            {
                anim.SetTrigger("move_up");
            }
 
 
            if (movement.y == -1 && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("move_down"))
            {
                anim.SetTrigger("move_down");
            }
        }
        else
        {
            anim.SetTrigger("anim_over");
        }
 
 
        transform.Translate(movement * speed * Time.deltaTime);
    }
 
}

Have you tried selecting the non-looping animations in your project tab and selecting “Loop Time?”