jeudi 21 février 2019

I need help trying to reverse logic in an IF statement in Unity C#

I'm using a simple GameObject[] which uses Game Objects as "navPoints" for a navAgent to move to.

I have a method which works simply like this:

  public void pickNextNavPoint()
    {
        ++navIndex;
        if (navIndex >= myNavPoints.Length)
            navIndex = 0;

    }

I then use a method :

public void FindDestination()
    {
        GetComponent<NavMeshAgent> 
        ().SetDestination(myNavPoints[navIndex].transform.position);

    }

This makes my NavAgent go to a NavPoint, then the next one and so on.

My question is simply, how can I alter this method to make it go in reverse using the same simple logic?

Aucun commentaire:

Enregistrer un commentaire