Esempio n. 1
0
    public override void Interact()
    {
        if (agent.IsArrived(transform.position, Destination.position))
        {
            return;
        }

        if (agent.enabled)
        {
            agent.isStopped = false;
        }
        else
        {
            agent.isStopped = false;
            agent.enabled   = true;
        }

        if (carryingCoroutine != null)
        {
            StopCoroutine(carryingCoroutine);
        }
        carryingCoroutine = StartCoroutine(GetInPosition());

        IEnumerator GetInPosition()
        {
            agent.SetDestination(Destination.position);
            while (!agent.IsDone())
            {
                yield return(null);
            }
            agent.enabled = false;
        }
    }