Files
AppleHillsProduction/Assets/Scripts/StateMachines/Dump/PigManBehaviour.cs

30 lines
709 B
C#

using System.Collections;
using UnityEngine;
public class PigManBehaviour : MonoBehaviour
{
private Animator _animator;
public bool canEatCards;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
canEatCards = true;
StartCoroutine(CheckIfShouldEatCard(2));
_animator = GetComponent<Animator>();
}
private IEnumerator CheckIfShouldEatCard(float seconds)
{
while(canEatCards)
{
yield return new WaitForSeconds(seconds);
if (Random.value < 0.62f)
{
_animator.SetTrigger("eatCards");
}
}
}
}