Instantiated prefab warps immediately
I have created a script that instantiates a prefab of an enemy at the location of it's parent (a spawner with the script that calls the instantiation). One of my spawners works perfectly 100% of the time and the enemies will spawn right where I want them (at the location of the parent object). I have a second spawner that was duplicated (ctrl + D) from the first spawner but moved to another location. This one works about 60-80% of the time. I have a third spawner created as a duplicate as well that works 0% of the time.
The only difference between the three is their location on the map so I'm guessing it has to do with my terrain. I have baked the map recently using the Navigation window and no changes have been made since. I have two screenshots to help.
The first is of the enemy immediately after being instantiated:
When I hit the step button to move forward one frame he warps randomly on the map as seen in this second image:
Any help is greatly appreciated as I'm out of ideas. Thanks in advance.
Answer by mekyleh · Apr 26, 2016 at 03:07 AM
I figured this out. The Nav Mesh Agent was not happy. What I ended up doing was disabling the Nav Mesh Agent component on the prefab. I then added a line to the spawner code that enables that component after the enemy has been instantiated. Now, it works on all of my spawners and I've been able to add more.
Your answer
![](https://koobas.hobune.stream/wayback/20220612075542im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity 2018.3.2 weird terrain painting 0 Answers
Grass glows over time, help? 1 Answer
every time i hover over my scene with a terrain brush everything turns black in the scene. 0 Answers
Spawn Hazard, clone behave diffrent 0 Answers
Terrain Disappear 0 Answers