Devlog 2: Navigating some Obstacles


Howdy.

This week I've mostly been working on map generation and navigation. The map generation wasn't too bad, but figuring out the navigation was a struggle.

For map generation, the process is pretty simple. The code basically just "walks" around, building a room and lining it up with one of the sides of the current room with a check to make sure nothing overlaps. I'm planning on improving it later, but it works for now.

For navigation, I originally wanted to avoid using NavigationRegion nodes (I'm coding in Godot, btw), mostly because the automatic obstacle-detection only detects walls that are children of the node itself. I decided to make a code-only version, since the docs said it would let me pick which node was the "root" node the walls had to be children of along with some other benefits. I thought it would be challenging and fun. I was correct about one of those.

My plan was to throw together a simple test scene and make sure the navigation maps were being made how I thought they were. As a short rundown, navigation in Godot is handled by the Navigation Server. The Server holds all the navigation maps that exist, each of which are made up of navigation regions, which are themselves made of navigation polygons. The polygons hold the data for what areas are walkable, and can be baked using collider data from other nodes to automatically mark areas as impassable. So the basic process is to make a polygon, bake it with the collider data, make a region, give the region the polygon, then set the region to a map. 

While that may seem complex, Godot comes with a handy navigation debug tool that makes all the polygons and regions visible. So I just needed to try and make a big square region, and if I could see it then I knew the code was working. Easy enough.

Except that no matter what I did, I could never get anything to show up. I knew what it was supposed to look like since I'd used it with NavigationRegion nodes before, but now it didn't work at all. So I spent a couple days slamming my head into that wall, before deciding to just work on the enemy navigation stuff and test with a NavigationRegion node. After finishing that, I went back to the code and tried again to get the region to show up. Still nothing.

Then I had an idea. I added one of the navigation enemies to the scene and ran it, just to see what would happen. If there wasn't a navigation region, then the enemy should've just stood in place, but instead it started running around. I realized, then, that the debug tools didn't actually use the server to find the regions, but instead used the NavigationRegion nodes directly. Since I didn't use those, the regions weren't being drawn, and my code had probably been working the entire time. Cool. Great. Wonderful.

With that figured out, I threw together some code to use the baked polygons and draw them manually, which worked fine. I tested it with the room generation to make sure it marked the walls as impassable, and that worked as well. Yay.

I'm planning on finishing navigation this week (which will likely involve using NavigationRegion nodes anyway, since now I know how to bake their polygons in code), then work on enemy-player interactions.

Whoo hoo.

Get TANIK Protocol

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.