-->

Thursday, 3 September 2026

Tankenstein NPC spawning and POIs

Hi.

We recently pushed the 0.3 update for Tankenstein which included a big upgrade to the terrain generation and spawning system. Because of those changes and because we've had some comments about tank spawning, I decided to write up some detail about how the terrain streaming works, and how tanks are spawned as part of that system.  

I've also included some information about points of interest (POIs), which govern how the AI navigates across the landscape after spawning.

In order to explain how tanks spawn it's necessary to know the basics of how the world streaming system works in general, because there isn't a separate spawn system for tanks. 

Spawning

Tankenstein uses an in house tool called Panzer Terrain. This handles real-time, procedural generation of terrain and game object spawning. As the player traverses the world, the landscape is spawned in as ~1km2 tiles. The height map is generated on the GPU using compute shaders, then handed off to the CPU to generate collision data.

 

GPU terrain generation based on camera position.

Once the height map and collision data have been generated for a tile, it is handed off to the game object spawning system which creates all the objects that appear on that terrain tile. This system works by subdividing the tile into smaller and smaller cells and attempting to spawn an object in each cell. This structure is known as a quad-tree and by testing for collisions at each node of that tree we can efficiently ensure spawned objects don't collide with each other.

Objects are spawned in the following order. Large compounds -> small compounds -> tanks -> wrecks -> scattered cover -> decals. There's a few extra steps such as flattening the terrain around compounds and generating the navigation mesh, but that is the order for the spawning of objects. Some objects such as grass, stones, rocks and trees are dynamically streamed, so they only appear near the player. But anything gameplay related is handled by the spawning system.

The spawning sequence slowed down to show each step.

Functionally this means that well before a player gets to a terrain tile, all the objects that can spawn on that tile have already streamed in. This includes tanks, wrecks and any other objects that can be scanned by the radar. 

For performance reasons tanks and compounds will remain inactive until a player gets within 1000m of them. Once the player enters that radius, they will wake up and start running their AI. This leads on to POIs, and how tanks use them to navigate the map.

POIs

Many of the objects that spawn are flagged as points of interest (POIs). This is a tag that tells the AI that an object is of interest to them. POIs are wrecks (including destroyed tanks), scrappers, recombinators and compounds. When out of combat, tanks will pick nearby POIs to investigate. They will travel to that POI, investigate, then pick another.
 
A compound showing points of interest highlighted in blue
 
If an area has many POIs in it, such as a compound after a fight, then it becomes more likely that a tank will pick a POI in that area, by virtue of there being many POIs. In fact, compounds are some of the more dangerous areas of the map because of this.
 
A tank investigate a wreck.

The combination of the tanks spawning with terrain and investigating POIs means that as the player traverses the wasteland, there will always be new tanks driving around, investigating POIs and occasionally fighting each other*. They never remain idle, because the aim of this system is to populate the world with challenging enemies that behave in a (mostly) intelligent but predictable way. 
 
Hopefully this gives a little more detail about how the spawning system works and how tanks navigate through the world after spawning. If you have any questions, I'm happy to answer them here, on steam or on discord. 
 
* We had to limit this to a 10% chance for a tank to start a fight, any higher than that and tanks would destroy each other before the player could get involved.
 

No comments:

Post a Comment