nav mesh bounds dynamically change size and location. BPs only, no C++.

Been trying to figure this out for a while now, so thought i’d bring in the big guns (you).

my game’s landscape is a grid based tile system. The player starts with a set number of tiles centred around 0,0,0, like this, the “dropped” areas are where the player and enemies can walk:


Think something like dungeon keeper logic.

As the game progresses they can add additional tiles around the edge, growing the world. Something like this:

As the player progresses they will uncover, enemy spawn points which will, you guessed it, spawn enemies. These enemies then use a nav mesh to move towards zero (the yellow building in the centre.

The problem is that the levels are technically infinite where the only real limitation is the players PC. There are systems that are going to be in place to make the player WANT to move to the next level, but nothing forcing them.
In theory the player could just continuously be spawning more and more of the tiles as the game continues.

I see a few options:

  1. Spawn a small nav mesh on each walkable tile (the ones that are “dropped” in these images.
  2. Change the X and Y size in the Nav Mesh bounds volume at run time to make sure all paths are covered. (so get the distance between the two furthest apart hexagon tiles on the Y axis, set that as the size of the box and then set it’s Y location to the average of the two locations. repeat for X)
  3. Make a massive (for example 1,000,000x1,000,000x500) NavMesh bounds volume and hope the player gets bored before they get that far.

1 and 3 feel like they’re the wrong way to go, i imagine they’re going to be very heavy on the players computer.

2 feels like the ideal way but i can’t seem to access those values through BPs. I know that they can be accessed via C++ but that is unfortunately beyond me, i tried.

There is an option 4 where i change the game rules to have a more finite world and have the Nav mesh cover the maximum possible area (similar to 3), This is probably the direction I’m headed at the moment but it still doesn’t feel like the “correct” way to do this.

Can anyone offer any advice, really struggling with this one. what would be the “proper” way to do this. (other than in C++, i know that would be best)

Appreciate any help people can offer. sorry for the long post.

Thanks.

You want to look into something called Navmesh Invokers.

This requires switching Navmesh Generation to dynamic, and also ticking “Generate Navigation Only Around Navigation Invokers” in the project settings.

Then you’ll need to add a Navigation Invoker component in the AI’s blueprint.

I can’t talk to the performance of this on an infinite world or with a hell of a lot of invokers but that should hopefully give you a push in the right direction for what you want.

1 Like

That is certainly a step in the right direction. Thankyou I appreciate the advice and certainly will be using those.

The only problem is that even using the navigation invokers it requires a navmesh bounds volume, which (unless im mistaken) also cannot be set at runtime via BPs. please do correct me if I’m wrong.

But either way, thank you for the help, Navigation invokers will certainly help.

So if using a static nav mesh then you would be right but as long as you set your recast nav mesh to dynamic, then what you can do is update its scale as your world grows.

So each time your map grows then you could check to see if it is larger than the bounds of the current navigational area and update if neceesary. for the change to be registered you will need to call navigation bounds updated in blueprint to see it reflected.

This in theory could give you an unlimited dynamic nav mesh, however…

This will get expensive before too long so just keep that in mind if this is the route you’re going to take.