using UnityEngine; public class LoopAnimation : MonoBehaviour { public string animationStateName; private Animator animator; void Start() { animator = GetComponent(); if (animator == null) { Debug.LogError("Animator component not found on the object."); } } public void ResetAnimationPlay() { if (animator != null && !string.IsNullOrEmpty(animationStateName)) { animator.Play(animationStateName, -1, 0f); } else { Debug.LogError("Animation state name is not set or Animator is null."); } } }