- Home /
Is there a way for me to find the walkable edges of my traversable game map?
Hi! So my problem is that I have several enemies that I want to move to the edge of the traversable game map. I am using A* pathfinding and the edge/vector they move to needs to be walkable and each enemy needs to find and move to a different edge/vector. If this matters my A* grid goes a little bit off the sides of what area is the game map/level. If they are more to the left of the traversable game map i want them to move towards the left edge/side of the map, if they are more to the right I want them to move to the right side/edge of the map. My problem is finding edges and making sure everyone goes to a different edge. I tried moving them an x/y position that was down and to the left/right and then changing the coordinates for subsequent enemies to move to, but this sometimes resulted in them trying to go to a location that was way off the map, thus standing still forever since no path could be found. I have also tried using quaternions and raycasts to find edges at different angles, but managed to get some kind of infinite loop going, due to (I think anyways) the raycast going in the wrong direction and/or never hitting the any of the edges of the map. I have considered hardcoding in all of the Vector2 edge points that they can move to(my game is a 2D game if that matters for my problem) but I would prefer not to have to do this since my game has randomly selected levels and each level is shaped a bit differently with different edges being spots the enemies could move too. Please help I have been trying to figure this out for the past 2 weeks. Also C# preferred.