Пример #1
0
    public override NodeState Evaluate()
    {
        Transform queueSpot = ai.GetQueueSpot();

        if (queueSpot == null)
        {
            ai.isInPosition = false;
            return(NodeState.FAILURE);
        }

        //float distance = Vector3.Distance(queueSpot.position, agent.transform.position);
        float distance = ai.DistanceBetweenSpots();

        if (distance > 2f)
        {
            Debug.Log("GOING TO POSITION");
            //ai.isInPosition = false;
            agent.isStopped = false;
            agent.SetDestination(queueSpot.position);
            //ticks++;
            Debug.Log(ticks);
            starting = false;
            return(NodeState.RUNNING);
        }
        else // if (distance <= 0.2f)
        {
            //notInPosition = false;
            ai.isInPosition = true;

            Debug.Log("IN POSITION TO ORDER");
            agent.isStopped = true;
            starting        = false;
            return(NodeState.SUCCCESS);
        }
        //starting = false;

        //return NodeState.FAILURE;
    }
Пример #2
0
    public override NodeState Evaluate()
    {
        Transform lootSpot = ai.GetQueueSpot();

        if (lootSpot == null)
        {
            return(NodeState.FAILURE);
        }

        float distance = Vector3.Distance(lootSpot.position, agent.transform.position);

        if (distance > 0.2f)
        {
            agent.isStopped = false;
            agent.SetDestination(lootSpot.position);
            return(NodeState.RUNNING);
        }
        else
        {
            agent.isStopped = true;
            return(NodeState.SUCCCESS);
        }
    }