How to control NavMesh agent parameters

Hello there,

I’d like to know if there is a possibility of changing parameters of NavMesh Agent script, for example, i’d like to change the “speed” and “acceleration” using a different script of mine, is that possible?

Thanks in advance.

Yes, (1) you’ll need a reference to the character in your script. (2) then you’ll need to get the NavMeshAgent component and finally (3) you can set the speed and acceleration at the appropriate time. The (untested!) c# code would look something like the below. Hope this helps.

public GameObject character;  // 1 (this will appear in the inspector)

private NavMeshAgent agent;

void Start()
    agent = character.GetComponent<NavMeshAgent>();   // 2

void Update()
  agent.speed = 8;      // 3
  agent.acceleration = 5;