Animator Not Play Animation Consecutively

I have three animations; straight, left, and right. The straight plays with load scene. After ending the animation, buttons appear and asks player to go which way, left or right. According to the button click, corresponding animation plays. And the game goes to the next junction so on so forth.
However, if the player clicks same direction more than once, Unity does not play the corresponding animation.
How can I play these animations? Thanks.

private void Awake()
{
    StartCoroutine(AnimDelay(strAnimTime));//it is Straight for the first time then changes accordingly.
}

public void DirectionController(string _direction)
{
    animName = _direction;
    leftButton.SetActive(false);
    rightButton.SetActive(false);

    StartCoroutine(AnimDelay(lrAnimTime));
}

private IEnumerator AnimDelay(float _time)
{
    clip.Play(animName);

    yield return new WaitForSeconds(_time);

    leftButton.SetActive(true);
    rightButton.SetActive(true);
}


Screenshot 2023-10-25 144812

Heyyo!
From the snippet of code you have shown, I’m not really able to debug what’s going on. For example, we are not able to see how DirectionController is getting used/when it’s called. Would you be able to share more of your code and setup so we can look at this better? Like the entire class, the member declarations for “clip”, “animName”, “leftButton”, and stuff like that!
One possible guess though:
It might not be explicitly passing the time to start the state in. You might just need to do: clip.Play(animName, normalizedTime = 0f); , in order to “rewind” the clip each time
Thank you!

Hi,
Thanks for the reply. Here is the whole script and details about buttons&function call (DirectionController)

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public class AnimationController : MonoBehaviour
{
    public GameObject leftButton, rightButton;
    public Animator clip;
    private string animName = "Straight";
    private readonly List<string> directionList = new();
    private readonly List<string> solutionList = new() { "Left", "Right", "Right", "Left", "Left", "Right", "Right", "Left" };
    private readonly float strAnimTime = 2.01f;
    private readonly float lrAnimTime = 2.67f;
	
	private void Awake()
	{
		StartCoroutine(AnimDelay(strAnimTime));//it is Straight for the first time then changes accordingly.
	}

	public void DirectionController(string _direction)
	{
		animName = _direction;
		leftButton.SetActive(false);
		rightButton.SetActive(false);

		StartCoroutine(AnimDelay(lrAnimTime));
	}

	private IEnumerator AnimDelay(float _time)
	{
		clip.Play(animName);

		yield return new WaitForSeconds(_time);

		leftButton.SetActive(true);
		rightButton.SetActive(true);
	}
}