- Home /
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?
ap
Answer by robertbu · Apr 17, 2014 at 08:10 PM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220613142950im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
... Can only be called on an Active Agent that has been placed on a Nav Mesh? 2 Answers
Nav Mesh Agent 0 Answers
Using a navmesh agent as a character controller 1 Answer
Random Position on Nav Mesh 1 Answer
Nav Mesh Agents Not working 0 Answers