I am trying to figure out how to spawn enemies and make them move randomly but only within a certain area on my tiled map.
Specifically, each map will have:
-
Enemy spawn points which each will spawn x number of enemies at random places around the spawn point.
-
Boundary rectangles which represent the edge of the map where enemies should NOT go to.
My question is how can I go about spawning the enemies ONLY inside these boundary rectangles?
Similarly, once they are spawned, how can I make them move randomly, but ONLY inside of the rectangles?
Regarding enemy movement, I am planning on having each enemy choose a random spot near them every so often and move to it. But like I mentioned, I don’t want that random spot to be anywhere outside the boundaries.
I am trying to not use physics but some sort of logic so the enemies will never randomly choose a spot outside of the bounds to walk to.
Any ideas on how to best approach this would be much appreciated.