gather-and-defend/Assets/Scripts/AnimationEntity.cs
Baptiste 6c23b4b99c v0
2023-06-13 09:47:55 -04:00

34 lines
687 B
C#

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