NavMesh Agent not updating (Setting) new path

Im using the NavMesh agent to move my “Inhabitants” around the scene. The desinations are set depending on what time of day it is. There are three destinations at present, a “Home” a “Work” and a “Hobbies” location.

Now the code is getting called, s the debugs and text is being called correctly. BUT the actual pathfinding isnt updating and they stay in the same place even when we move on to another part of the day… Havny really used NavMesh pathfinding before, so might be simple. But as far as im aware calling the SetDestination method of the NavMesh Agent is all you need to do to update the path.

Heres the code.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;	

// Now using unity built in nav mesh for pathfinding.
public class NavMeshPathfinding : MonoBehaviour {

	public enum Destinations{
		
		home,
		work,
		hobbies
	};
	
	Destinations destination;

	// The actual destinations in the scene.
	public GameObject home;
	public GameObject work;
	public GameObject hobbies;
	public Text destinationText;

	NavMeshAgent agent;

	private GameObject GM;

	private WorldTime worldTime;

	// Use this for initialization
	void Start () {

		agent = GetComponent<NavMeshAgent>();
		GM = GameObject.FindGameObjectWithTag(Tags.GM);
		worldTime = GM.GetComponent<WorldTime>();

		destinationText.text = "Idle";
	
	}
	
	// Update is called once per frame
	void Update () {

		// when its a weekday..
		if (destination != Destinations.home && (worldTime.timeOfDay == WorldTime.TimeOfDay.Morning || worldTime.timeOfDay == WorldTime.TimeOfDay.Nightime) )
		{
			
			destination = Destinations.home;
			GetNewDestination();

		}
		
		else if (worldTime.day == WorldTime.Days.Saturday || worldTime.day == WorldTime.Days.Sunday)
		{
			
			if (destination != Destinations.hobbies && worldTime.timeOfDay == WorldTime.TimeOfDay.WorkTime)
			{
				destination = Destinations.hobbies;
				GetNewDestination();
			}
			
		}
		
		
		else
		{
			if (destination != Destinations.work && worldTime.timeOfDay == WorldTime.TimeOfDay.WorkTime)
			{
				
				destination = Destinations.work;
				GetNewDestination();
			}
			
		}
	
	}

	public void GetNewDestination ()
	{

		if (destination == Destinations.home)
		{
			Debug.Log("Heading to" + destination);
			agent.SetDestination(home.transform.position);
			destinationText.text = "Heading home";
		}

		else if (destination == Destinations.work)
		{
			Debug.Log( "Heading too "+ destination);
			agent.SetDestination(work.transform.position);
			destinationText.text = "Time for work";
		}

		else if (destination == Destinations.hobbies)
		{
			Debug.Log("Heading to: "+destination);
			agent.SetDestination(hobbies.transform.position);
			destinationText.text = "Now for some me time.";
		}

	}
}

So they head to the inital desination “home” and then stay there…

So what am i doing wrong troops?

Thanks in advance…

In Unity 5, NavMesh Agents will not automatically resume when a new destination is set. You need to manually call Resume()

This is noted in the Unity 5 Upgrade Guide Unity - Manual: AI in Unity 5.0