So right now I have cannons set up on the left side of the screen and monsters coming from the right. When I place my monsters manually (be 1 or a 1000) “Monster 1 Prefab” on the scene, everything works just fine, the enemies walk towards the cannons, the enemies attack if they are near the cannons and the cannons die if hp <= 0. The problem I am having is that I have an enemy spawn location and a script which generates monsters every x seconds in different locations… this however messes up my monster script somehow because when the monsters get instantiated, they walk towards the cannons as they should but they keep walking when they reach the cannons… and I have no idea why… here is the code for the enemy spawn location:
I might have few misspelled words, but its because I handwritten this from my other comp so that shouldn’t be a problem because it does what it should, the biggest thing I am thinking about is maybe I am instantiating all the enemies as 1 enemy, or that I can’t have them as prefabs but have them as actual gameObjects? One other thing to note is that I don’t know how to find a gameObject or a prefab in my folder in a script so that is why it is public because I just dragged and dropped it. Maybe it has something to do with my enemy script which I can post but why do the enemies work just fine when I manually place them but not when they get instantiated via script…
Unfortunately this is wayyy more complicated than it needs to be, but I just couldn’t figure out how to make the enemy attack and access the cannon’s life, so I had to make OnTriggerStay, which will probably cause some problems down the road… but anyways, there it is. I know its a lot to ask but if there is a simpler way of doing all of this I would appreciate the example/template/help. Thanks