How to make avoidable obstacles in game?

Godot Version

4.2.1

Question

I started working with navigation regions 2d recently and and I read many topics and watched some videos but I can’t find solution for my problem.

I’m making RTS game and I want to make my characters avoid buildings that you’ll build. I want make something like in warcraft 3 for example: when you build something and your characters find way to avoid these buildings. The problem is that they go straight and can’t pass through static body instead of bypassing it. I tried navigation obstacle 2d but it wasn’t work as I wanted to: player just did not reach the object and get stuck there. I also tried enter and travel costs but it didn’t work for me

Is there any way to make my characters avoid place where building are? Like making hole in nav region right in game and not in engine?

The navigation mesh is all that counts for pathfinding so you always need to update the navigation mesh if you add new objects like buildings.

All visual or physics objects are entirely meaningless for pathfinding as long as they are not baked to a navigation mesh surface. To bake all you need to do is make sure that the placed object is parsed in the navigation mesh baking process. The settings can be found on the used NavigationPolygon/NavigationMesh resource.

The NavigationObstacle does affect the avoidance but not the pathfinding.

Well, I made when building appear it would have “Polygon2D” node, so when navmesh would rebake, there would be like “hole” on building spot.

Thanks you a lot! It took so much of my time

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.