Beispiel #1
0
    public static AIPathingWaypoint GetNextWaypoint(AIPathingWaypoint currentWaypoint)
    {
        if (Instance == null)
        {
            Debug.LogErrorFormat("AI Pathing Manager is null! Its not supposed to be!");
            return(null);
        }

        return(Instance.GetNextWaypoint_Internal(currentWaypoint));
    }
Beispiel #2
0
    private void SetNewWaypoint()
    {
        currentWaypoint = AIPathingManager.GetNextWaypoint(currentWaypoint);
        Vector3    vectorToTarget = currentWaypoint.transform.position - transform.position;
        float      angleToTarget  = Mathf.Atan2(vectorToTarget.y, vectorToTarget.x) * Mathf.Rad2Deg;
        Quaternion q = Quaternion.AngleAxis(angleToTarget, Vector3.forward);

        transform.rotation   = q;
        _previousDistance    = Mathf.Infinity;
        hasArrivedAtWaypoint = false;
    }
Beispiel #3
0
    private AIPathingWaypoint GetNextWaypoint_Internal(AIPathingWaypoint currentWaypoint)
    {
        int currentIndex = -1;

        if (currentWaypoint != null && !currentWaypoint.IsFinalDestination)
        {
            if (_allPathingWaypoints.Contains(currentWaypoint))
            {
                currentIndex = _allPathingWaypoints.IndexOf(currentWaypoint);
            }
        }

        return(GetNextWaypoint_Internal(currentIndex));
    }