lost nav agent target memory in prefabs

why does my nav agent AI game object lose its target memory when i put it in prefabs so that i am unable to spawn it as a spawend AI nav agent?


I assume you have a public variable that you initialized to your target by dragging and dropping? If so, then yes you will lose them when you make a prefab. The issue is that a prefab is not associated with any scene. You could Instantiate that prefab into any scene, so scene references don’t work. You have to dynamically initialize variables in Awake() or Start(). I don’t know how your game is structured, but usually GameObject.Find() or GameObject.FindWithTag() to initialize the variable.