Exemplo n.º 1
0
 public bool HaveReachedDestination()
 {
     if (npc.myNavMeshAgent.remainingDistance <= npc.myNavMeshAgent.stoppingDistance && npc.myNavMeshAgent.pathPending == false)
     {
         npc.StopWalking();
         return(true);
     }
     else
     {
         npc.KeepWalking();
         return(false);
     }
 }
Exemplo n.º 2
0
    void Pursue()
    {
        npc.UpdateStateIndicator(stateIndicatorColor);


        if (npc.myNavMeshAgent.enabled && npc.pursueTarget != null)
        {
            npcMove.MoveTo(npc.pursueTarget.position);
            npc.locationOfInterest = npc.pursueTarget.position;              // used by if npc goes to alert state.

            float distanceToTarget = Vector3.Distance(npc.transform.position, npc.pursueTarget.position);
            //  Check npc can see target and is in range.
            if (distanceToTarget <= npc.sightRange && npcSight.CanSeeTarget(npc, npc.pursueTarget))
            {
                ToRangeAttackState();
                npc.StopWalking();
            }
        }
        else
        {
            ToAlertState();
        }
    }
Exemplo n.º 3
0
    void Patrol()
    {
        if (waypoints.Length > 0)
        {
            npcMove.MoveTo(waypoints[nextWaypoint].position);
            if (npcMove.HaveReachedDestination())
            {
                nextWaypoint = Random.Range(0, waypoints.Length);
            }
        }

        else        //  Wander about if there are no waypoints
        {
            if (npcMove.HaveReachedDestination())
            {
                npc.StopWalking();
                if (RandomWanderTarget(npc.transform.position, npc.sightRange, out npc.wanderLocation))
                {
                    npcMove.MoveTo(npc.wanderLocation);
                }
            }
        }
    }