float distance = Vector3.Distance(transform.position, player.position);
var State = distance > 10 ? AIState.TowardsPlayer : AIState.Right;
Debug.Log(distance);
switch (State)
{
case AIState.TowardsPlayer:
transform.LookAt(player.transform);
transform.position += transform.forward * approaching * Time.deltaTime;
break;
case AIState.Right:
transform.position += transform.right * 1f * Time.deltaTime;
Invoke("AIState.TowardsPlayer", 2f);
break;
I want it to have a slight delay after AIState.Right finishes its execution before moving onto AIState.TowardsPlayer. I put Invoke but it didn't work.