How would you manage wandering AI in a sandbox game?

I want to try out wandering AI that has their own life and random decisions based on personality.

However, in my game I let the player build whatever, wherever he wants. Is there a smart way to make sure the player doesn’t block the AI path from for example their house to the beach? Keeping in mind the player is allowed to place the AIs house anywhere? What is to stop the player from surrounding the house with a fence for instance.

How can this be achieved with as little disturbance to gameplay as possible?

You will have to update the NavMesh whenever something new is built. Alternatively you can add NavMeshObstacle components to the built objects to have this update be done for you. As for the gameplay interference, you’ll have to get a bit creative. You could maybe make fences something an agent can skip over by adding NavMeshLinks to them, or make a check in your building code to see if the placement is valid (doesn’t block off an entire area etc. Difficult stuff, would take a lot of testing and thinking.)

1 Like