Godot Version
4.4dev7, 4.3
Question
In my top down 2d game I have two groups of agents: player minions and enemies. Both groups are using navigations. World map contains gates. A gate follows this set of rules:
- Gate can belong to player (minions) or enemy
- Agents that match gate can pass freely like it doesn’t exist.
- Gate can be destroyed. When destroyed everyone can pass freely.
- Destroyed gate can be rebuild. Rebuilding gate works as new
Here is example situation with friendly gate. Minions that need to go to some point beyond gate will have path calculate like there is navigation region. Enemies navigation that targets things on the other side will be calculated like there is end of navigation. Once enemies get closer to gate they will attack it. Once gate is destroyed navigation for enemies will work the same way as for minions.
Here is my current solution.
I separated world map into smaller regions. On image you can see “common” regions on left and right and then “gate” region in center. “Gate” region only have layers turned on for players, so enemies can’t go. When game starts I have a script that makes a copy of “gate” region but sets layers that only allow enemies to pass. New region is disabled by default. When gate is destroyed this region is activated. When gate is rebuilt then region is deactivated.
Solution itself works fine. However, development experience is very suboptimal. I have to create many regions manually and do a lot of pixel hunting to ensure edges are aligned. It means every time I move anything, I have to do it again. Process is very error prone and I have to test in game with real agents.
My main question: is there a better way to avoid manual error prone labor?. Ideally, something that works out of the box, even if it’s 3rd party navigation plugin.
Another solution I was thinking of is to chunk regions myself from code, but don’t know if it’s possible and if it’s a good idea.