How to gradually increase the speed of a NavMesh agent?

So I have zombies that are clones of an original zombie and they all fallow the player, their speed right now (set in the inspector under NavMesh Agent) is 7.5. This is a good speed, however not for when the game first starts off. What I am asking/trying to do is make it so the zombie’s start off with a speed of 1, then after 10 secs go to 1.5, then after 10 more secs go to 2, and so on and so on, then stop at 7.5 (for their maximum speed) at 130 seconds. How would I do this? I’m thinking writing the code in a C# script and then attaching it to the OG zombie. Any suggestions? Thanks, I do not know how to write this code.

@ChompIV Constantly increasing a NavMeshAgent’s speed is best done in a Coroutine just as screenname_taken suggested - Coroutine Unity Tutorial.

You’ll want to loop your Coroutine in order for something to happen over and over again (in this case: every second). While loops are a good option. If you want to suspend the Coroutine execution and wait “amount of seconds” then - do something afterward; WaitForSeconds can be used to do just that.

Tested this and it gives the desired effect. Adds 0.5f to agent.speed every second and stops the Coroutine when agent.speed reached 7.5f. Agent will move to dest(C#):

    UnityEngine.AI.NavMeshAgent agent;
    //agent's destination 
    public Transform dest;
    //max speed that can be attained
    float speedCap = 7.5f;

	void Start () 
        //get NavMeshAgent component from gameObject that this script is attached to 
        agent = GetComponent<UnityEngine.AI.NavMeshAgent>();
        //agent will move to "dest" 
        agent.destination = dest.position;
        //begin increasing speed (StartCoroutine)
        StartCoroutine("IncreaseSpeedPerSecond", 1f);

    IEnumerator IncreaseSpeedPerSecond (float waitTime)
        //while agent's speed is less than the speedCap
        while (agent.speed < speedCap)
            //wait "waitTime"
            yield return new WaitForSeconds(waitTime);
            //add 0.5f to currentSpeed every loop 
            agent.speed = agent.speed + 0.5f;

Feel free to ask me to elaborate on anything that isn’t clear and I’ll be glad to answer you to the best of my ability!

A side note: There are awesome tutorials related to NavMesh here and I highly recommend you check them out!

You just need to use NavMeshAgent.Speed.
Increase it in a Coroutine every few seconds.