- Home /
Enemy clone not following script
I created move spots for my enemies to randomly patrol, but I kept getting an error that my array index is out of bounds. I realized that it wasn't because of the code but because one of the spawned clones just ignored the move spot gameobjects.
This is how the clones properties are supposed to look like
And then the last clone just ignored the move spots
no they just need to populate their array.
Answer by logicandchaos · Aug 10, 2021 at 04:36 PM
Did you fill the array manually from the inspector? You will have to fill it from code I would do it in the Start function. There are many ways to do this, your move objects are just transforms, so you can put tags on them and use them to get them all with FindGameObjectsWithTag(string tag); then add them all to the enemies' MoveSpot array probably with a loop in the Start method in the EnemyController script.
Thank you
It turns out that my spawner script was on two different gameobjects, after removing one it worked fine
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Looping Between Waypoints 1 Answer
Enemy stopped at first waypoints. 1 Answer
Microsoft Visual C# Compiler error 0 Answers