Search Unity

How would you manage wandering AI in a sandbox game?

Discussion in 'Navigation' started by mrCharli3, Apr 22, 2019.

  1. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    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?
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    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.)
     
    mrCharli3 likes this.