rdInst Tutorial 4 – Using rdInst from C++

You are able to do everything you can in Blueprints in C++ as well – in fact, you can do more.

It’s fairly simple, just include the rdInst Module in the same way you would include other Modules, include the header, and go from there.

Step 1. Add the rdInst Module to your project and include the Header

In your C++ project, open your projects “.Build.cs” file and add “rdInst” to your DependencyModuleNames (Public or Private).

That will include the Module and add the Modules folder to the include search path.

Now, in the files you wish to reference ArdActors from, just #include “rdActor.h”

Step 2. Add Code

Now you can either derive your own classes off ArdActor, or pass references/pointers to your own methods to work with them. In this tutorial we’ll derive off it and add an Instance from a passed in Static Mesh, here is the header file for the example Class:

And this is the cpp OnConstruction method:

Step 3. Add to the scene

That’s all there is basically – you should be able to compile your code and add the new Actor class to the level.

You will need to add a Root Component from the Editor now to make it movable, then just set the StaticMesh.

You can also easily create the Instances straight from their HISMC’s, the above example can be replaced with the code below to create the Instances in the most optimal way.