rdInst Tutorial 11.3 – Simple VAT Spawning


This tutorial shows how to set up a rdEntity DataAsset to use as a simple VAT entity and how to spawn from that.


Step 1. Set the Instance Settings

Firstly, we want to set up the settings used by the VAT ISMs – basically, we just want to turn off collision, turn on WPO velocities (helps remove movement smear in TSR modes) and set the number of Custom Floats to 4 (used by the VAT animation shader).

Right-Click on the VAT Static Meshes and choose rdInst->Instance Settings

Set the settings to be like these:

Step 2. Create the edEntity DataAsset

Right-Click in an empty part of a Content Browser File List and Select New Miscellaneous->DataAsset from the list

Search for “rdentity” and select the “rdEntityDescriptionDataAsset”.

Open it up and set it as below:

This describes the VAT along with it’s animations and movement type.

The AnimDescriptions are a way to generically assign lists of anims for each movement type a movement class caters for. The ChaseMovement has 2, an Idle set and a Chase set. Each Entity spawned takes a random anim from each set and uses those (for variation). Each item in those sets just describes the start and stop frames for that anim in the VAT textures.

The Preferred Movement is the movement class to use for this Entity Type (can be overridden from the Spawn functions).

The Spawn Anim can be none, a “raise from the ground” or a “Fall from the sky”, taking Spawn Anim Time and starting from it’s spawn location + Spawn Anim Offset.

The Spawn Weight is for when you’re spawning from a list of Entity Types, this weight (between -1.0 and 1.0) can be use to control which get spawned more/less.

You can also control spawning weight (how often Entities get spawned close to players) from the Players themselves, implement a function called “rdGetPlayerWeight” and tick “Call in Editor” property, give it 2 return values, playerChaseWeight (used to weight the Chase towards players) and playerSpawnWeight (the weight to control how many spawn around this player).


Step 3. Add a NavMesh and an ECS Spawn Volume

The ChaseMovement class uses an existing NavMesh to build it’s own nav cache, so firstly add a Nav Volume to the level and position/scale it to cover the area you’re wanting to move around.

Then add a rdNPCSpawnActor Volume to the level and position/scale it to cover the NavMesh.

If you’re wanting MultiPlayer, make sure to enable “Client Side Navigation” in your Project Settings->Engine->Navigation System:


Step 4. Spawn some Entities

The rdInst Subsystem has all the functions needed to work with the rdEntity System. These spawns should be called on each client (and server) and not be replicated. The players themselves will be synchronized between clients and any Proxies are replicated, but the ECS system should be run on each client to avoid unnecessary network traffic for potentially tens of thousands of Entities.

Here is a simple SpawnMultiAroundPlayers – randomly chooses from the list of Entity Descriptors and spawns between inner and outer radii (non-intersecting) around the players.

To control which players to spawn around, you can use the Function mentioned in Step 2.

By default, all the Player Spawn Weights are 0 – when they are, no weighting is used. If any are non-zero all players become weighted. To only spawn around one player, just return 1.0 for its weight while still returning 0.0 for the others – you can use 1.0 on as many as the players as you want.

To spawn more on some players and less on others, set the ones you want more spawned around as 1.0 and for the ones with less, something like 0.5 or 0.3.


If you’re only wanting to spawn 1 type of Entity, there’s the “rdSpawnAroundPlayers” as well.

If you’re wanting to spawn around a specific point rather than the players, there are the rdSpawnAroundPoint and rdSpawnMultiAroundPoint.

The rest aren’t implemented yet, but there will also be:

There will also be routines to load/remove baked NPC data at runtime.