I'm attempting to make a falling animation activate after my Player steps on a platform for a certain amount of time. I'm trying to do this in Unity with c#.
I've tried to use a coroutine to execute code over time but it does not seem to work in an on trigger enter method. I've also tried to use a bool and a timer variable to see if the player is touching for set amount of seconds.
IEnumerator OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player")
{
yield return new WaitForSeconds(5);
myAnimationController.SetBool("FallWhenTouched", true);
Debug.Log("It Worked");
Debug.Log(other.gameObject.name);
}
}
I would just use standard Invoke function with time delay.