Navmesh weirdness

Hi guys,

I have this Scipt attached to a Worker. The Worker is a prefab that is insantiated in runtime. The prefab has a NavMesh agent component with a baked navmesh

using UnityEngine;
using System.Collections;

public class Geldwert : MonoBehaviour {

	 public static int Preis  = 10 ; 
	 private NavMeshAgent agent ;
	  Vector3 dest ;




	  public  void Arbeite ( ){

		Debug.Log(" Arbeit ArRRR! ") ;


		Laufen () ; 


	}

	


	// Use this for initialization
	void Start () {

		dest = new Vector3 (-1.4f,0.4f,-17) ;
		agent.SetDestination(dest);




			
	}
	void Awake(){


		agent = GetComponent<NavMeshAgent>();
	}

		

	// Update is called once per frame
	void Update () {




	
	}

	void Laufen(){


		Debug.Log(" Position geändert" ) ;
		dest = new Vector3 (-1.4f,0.4f,-11) ;
		agent.SetDestination(dest);

	}
		

		}

The Problem is, that the navmesh agent goes to the position that I set in the start function. But after that, he just doesnt react to the new vector 3 data I give him if I call the function Laufen , that is controllable from another script.

Edit : I updated the code, but now I get the following message :

“SetDestination” can only be called on an active agent that has been placed on a NavMesh.
UnityEngine.NavMeshAgent:SetDestination(Vector3)
Geldwert:Laufen() (at Assets/Geldwert.cs:59)
Geldwert:Arbeite() (at Assets/Geldwert.cs:18)
Arbeitsablauf:OnGUI() (at Assets/Arbeitsablauf.cs:41)

Arbeitsablauf Script :

using UnityEngine;
using System.Collections;

public class Arbeitsablauf : MonoBehaviour {


	bool Arbeiterkauf ; 

	 int Guthaben = 20 ; 
	 public Vector3  Spawnpunkt;
	 public GameObject Workers  ;
	SpawnSpot[] spawnSpots ;
	public Geldwert scriptReference ;

	// Use this for initialization
	void Start () {
		
		 spawnSpots= GameObject.FindObjectsOfType<SpawnSpot>();
			
	}

	void OnGUI (){


		// Anzeige unseres Guthabens ARRRR!
		GUILayout.Button("Guthaben: " + Guthaben.ToString());
	
		// Arbeiter kauf
		if(GUILayout.Button("Kaufe Arbeiter Klein") && Guthaben >= Geldwert.Preis){
			Arbeiterkauf = true  ;
			Guthaben = Guthaben -10 ; 
			SpawnSpot mySpawnSpot = spawnSpots [Random.Range (0 , spawnSpots.Length) ] ;
			Instantiate(Workers,mySpawnSpot.transform.position, Quaternion.identity );

		}


		if(GUILayout.Button("Holz holen")&& Arbeiterkauf == true ){
			// OnGUI Steuerung  und Erstellung des Arbeiters 

		scriptReference.Arbeite();


		}


		}
}

You are setting the destination in each Update hence each frame the NavMesh requires to calculate the path and then move there but before moving it again requires to calculate the path.

You need to set the destination once only after certain condition occurs like enemy has a different target than the previous one.