How to make a NavMeshAgent move in the direction it is looking?

I have a navmesh agent I’m trying to move off another gameobject below it. I’m trying to move it forward in whichever direction it is looking by telling the agent to move in front of where the eyes are looking. This code moves the agent in a direction but not where it is looking. How can I make the agent move the direction the eyes of the agent are looking? Thanks

public float distance = 10f;

    void OnTriggerStay(Collider c)
    {
    
    
  c.GetComponent<StateController> ().agent.destination = c.transform.position + c.GetComponent<StateController> ().eyes.forward * distance;

    
    }

What do you mean? Do you need an agent finding target? so it must be SetDestination

I have the same problem. @DJGhostViper : Have you find a solution?

Try use:

 void OnTriggerStay(Collider c)
 {
     void sc = c.GetComponent<StateController> ();
     sc.agent.destination =  c.transform.position + sc.eyes.forward;
 }

NavMeshAgent are especially usefull when you make a RTS-like game. Setting the destination of your units allow them to use the built-in path finding algorithme.

Using it this way seems strange for me but here is the solution :

void OnTriggerStay(Collider c) {
    float distance = 10;
    c.GetComponent<StateController> ().agent.destination = c.transform.position + c.GetComponent<StateController>().eyes.forward * distance;
}

(Not Tested)

In fact you say to your NavMeshAgent to move forward, corresponding to Vector3(0, 0, 1). You need to specify the distance or the movement will be almost invisible.

Edit : Nevermind, i’ve not seen the “OnTriggerStay”, well if you need to move forward OnTriggerStay it make sens… just use this :

c.transform.position + c.GetComponent<StateController>().eyes.forward

As Woltus said