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(); } private IEnumerator CheckIfShouldEatCard(float seconds) { while(canEatCards) { yield return new WaitForSeconds(seconds); if (Random.value < 0.62f) { _animator.SetTrigger("eatCards"); } } } }