What is the most efficient way to create a "walkable"area for 2D games?

Hi everyone,

This is just a theoretical question but, I am thinking of starting a 2D game and would love to get your input on what is the best solution (performance-wise) to define walkable areas (basically the are in which a player may move a character and where agents move) for a 2D game like Sword & Sorcery or any other second-person perspective games.

Please consider both point & click movement as well as realtime (X&Y axis).

  • use colliders and test every cycle before moving;
  • adultered navmesh 2D hack;
  • any other…

Thanks

In my experience, when Unity’s NavMesh won’t cut it, Node- or Grid-based A* algorithms tend to be the best balance between ease of setup and final performance. Wikipedia actually has a really good article on A*, complete with pseudocode.

@deprofundiis
One solution is to have a special Tag for the walkable floor areas. Say you have a floor that the player is allowed to walk on. Give it a tag named “Walkable”.
Then your script is generating Raycasts downward to detect the tag of the current floor. If the floor below the player does not contain the tag “Walkable”, then the player is not allowed to move there, IF the floor below the player does contain “Walkable”, then the player can move to that location.