using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayAnimation : MonoBehaviour { [SerializeField] Animator _objectAnimator; [SerializeField] string _AnimatioName; bool _animationPlayed; private void OnTriggerEnter(Collider col) { if (col.gameObject.tag == "Player" && !_animationPlayed) { PlayAnim(); } } public void PlayAnim() { _objectAnimator.Play(_AnimatioName); _animationPlayed = true; } }