rdInst Tutorial 16 – Adding Instances using Distributed Transactions

Last Updated: 2nd February 2023

If you’re wanting to add a lot of Static Mesh Instances to your level during run time, but you don’t want the game to slow down or jitter, you can limit how many instances you add per frame, and spread the addition over multiple frames.

That’s what rdInst does with the rdAddInstances_DT() method/Node.

You pass it a Static Mesh and a TArray of transforms, and how many transactions Per Tick you want to limit it to – rdInst does the rest.

So in this tutorial we’re going to add 1000 randomly placed tree instances every 5 seconds into the level while playing. It’s then possible to move around along with monitor the FPS rate to check the smoothness.

Step 1. Create a Blueprint Subclassed from rdActor

Create a new Blueprint subclassed from rdActor so we have access to our instancing nodes, then open that blueprint in the Blueprint editor and create a new Function called “AddInstances” – make it look like the below code:

Step 2. Add some code to the Tick event to fire every 5 seconds

Now make the Tick Event in the Blueprint look like the snapshot below:

Step 3. Done! Now just add one to your level and play.

You should be able to see how much smoother it is to add the instances distributed over frames. Play with how many you add each frame to see the range of performance. Of course, as it’s not removing the instances, it will slow down over time.