Enemy spawner, grids, etc

We are starting to work with this tool and I have a few questions:

  1. I have a large top-down open world. There are locations on the map, such as a factory, a military base, etc. I would like the most enemies (zombies) to appear in these places, and much fewer in open areas - 30:10 - is a local grid solution a good solution?
  2. In runtime, is it enough to add an opponent on the map and he will be able to handle it? NavMeshAgent`s from Unity need to be targeted at navmesh to add correctly, do I have to do the same here?

That’s it for now.


  1. I’d use some kind of weighted sampling for this. Have a few keys points and spawn a person near those key points with a large probability, and spawn anywhere in the world with a low probability.
  2. Should be enough to just add them to the map. If you want to get the closest point on the navmesh you can use AstarPath.active.GetNearest.
    Vector3 PickRandomPoint()
        Vector2 randomDirection = Random.insideUnitCircle * maxWanderingArea;
        Vector3 point = initialPosition + new Vector3(randomDirection.x, 0, randomDirection.y);
        if (IsPointInWalkableArea(point))
            return point;
            Debug.LogWarning("Generated point is not in a walkable area. Retrying...");
            return PickRandomPoint();

When its start i save initialPosition of zombie
PickRandomPoint() - find random point in area from this point to maxWanderingArea
Then check if this point in on walkable area

    bool IsPointInWalkableArea(Vector3 point)
        GraphNode node = AstarPath.active.GetNearest(point).node;
        return node != null && node.Walkable;

if not - find another, if is - move to this point. Now i need make spawner with probability system :slight_smile: