using System.Collections; using System.Collections.Generic; using UnityEngine; public class AnimationEntity : MonoBehaviour { private Animator _animator_entity; private bool _doSomething = false; private bool _isDead = false; void Start() { _animator_entity = GetComponentInChildren(); } void Update() { if (_doSomething && _animator_entity.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f) { Idle(); _doSomething = false; } } public void Idle() { if(!_isDead) { _animator_entity.Play("idle", 0, 0f); } } public void Walk() { if(!_isDead) { _animator_entity.Play("walk", 0, 0f); } } public void Attack() { if(!_isDead) { _animator_entity.Play("attack", 0, 0f); _doSomething = true; } } public void Die() { _animator_entity.Play("die", 0, 0f); _doSomething = true; _isDead = true; } }