Tower Defense - Making the Player move only spesific places

Greetings everyone!

I am creating a top down tower defense game with tiles. So i have 2 tilemaps, one is for green area (for towers and players) and one is for the road of enemies. I want the make player walk in only on green area not on road area. How to approach that idea? What’s the keyword and some tips for that? There is smth. to done with colliders maybe. But i couldn’t understand exactly.

I think what you’re looking for is pathfinding. This takes in a start position and an end position, and tries to find the fastest way from one point to another without touching any obstacles.

If your track/room is procedurally generated, or the course that enemies may take is dynamic, you need to use a pathfinding algorithm. There are some free 2D pathfinding assets that can help you get this set up very quick and easy. Ill link them, just ask.

However, like in the case of bloons tower defense, where all enemies take the same route, that can be precalculated before-hand, using a pathfinding algorithm is a bit overkill for that many agents. A simpler way is to use the edge collider 2D component, to draw the rough track that they take, and create a movement script that moves each agent to the next vertex of the edge collider.

Tell me which option you want to go for, and ill link the relevant scripts/resources below. @thekrocker

Thanks a lot sir for your all information! I used path objects, so that they move towards to it, if finds, it goes the next path.

What i am trying to find is, (my game is like bloon tower defence) My character(there is a moving character with w-a-s-d to repair towers) should not be able to go Enemy road. Can i fix that with edge collider?