I have a 2D game with a single large background image. I want to constrain the character to only be able to move along certain paths. I've seen a suggestion to accomplish that with invisible/transparent tilemaps. Is there a way to do that using some other object type? (like 2D Areas) Or are tiles the only way to create no-go zones for the character?
Constrain character movements without tilemap?
- Best Answerset by LeonShernoff
LeonShernoff You may be able to make invisible staticbodies if you're handling collisions with the built-in physics engine
If you manage the board yourself (using an array for instance), you can always check in movement code if the next cell is forbidden or not, and allow the character to move or not, with sound/visual effect.
It's just depend how big is the world and how it is modelled (using noise or hand made), if size if not too big, array or even dictionary for scattered map with only a few tile with special behaviour (wall, resource, trap, ...), could be better/faster.
JusTiCe8
That's a good thought, but the whole point is that we want "free movement", not jumping from one square cell to the next.
09kingarthur
Thanks; I'll give that a try.
- Edited
LeonShernoff I want to constrain the character to only be able to move along certain paths. I've seen a suggestion to accomplish that with invisible/transparent tilemaps. Is there a way to do that using some other object type? (like 2D Areas)
Navigation meshes?
4.x https://docs.godotengine.org/en/4.0/tutorials/navigation/navigation_introduction_2d.html
3.x https://docs.godotengine.org/en/3.6/classes/class_navigation2d.html
navigation demo for 3.x https://godotengine.org/asset-library/asset/117