Section 3.3. Setting our Randomization and Instance settings

We needed a convenient way to store the data used for the Randomization and also the StaticMesh Instance settings.

Each different Static Mesh has to be able to have it’s own unique settings – but it couldn’t tie that Mesh to the plugin at all.

The Same with the Randomization, except that data needed to be store in the Actor instances themselves in the level, but also with the ability to over-ride those settings at any stage with settings in a ChildActorComponent.

That’s where UserAssetData comes in, It is a simple Struct that Components have an Array of. We are able to Subclass that Struct and add it to the Components Array.

All we have to do is add a new element to the AssetUserData Array, and assign it’s class to our rdRandomizeAssetUserData Struct. This contains all the settings we need, just expand it out and edit the values to create your Randomization data.

Now we have extended the Actors with our Randomization settings, when the Child Actors and Instances are created, these settings are used as the parameters.

It’s also possible to set these up from Tags, they are then compatible with the Blueprint Only versions of this class.

When Randomizing the Actors/Instances, if an AssetUserData Struct isn’t found – it looks for the tags and creates an AssetUserData from those.

The other AssetUserData Struct of interest is the one for Static Mesh Instances. rdInstAssetUserData. You set these from the StaticMesh Editor, in the Details panel near the bottom. The values should be fairly self explanatory. The Inst Flags is a Bitfield with the Bit Values as described below the image.

With this, all instances created from this StaticMesh will be with these settings.

If you want to use the same StaticMesh, but with different settings, Duplicate the Mesh and change the settings on one.

rdInst_CastShadow 0x00000001 (1)
rdInst_CastStaticShadow 0x00000002 (2)
rdInst_CastDynamicShadow 0x00000004 (4)
rdInst_CastFarShadow 0x00000008 (8)
rdInst_CastInsetShadow 0x00000010 (16)
rdInst_CastHiddenShadow 0x00000020 (32)
rdInst_CastShadowAsTwoSided 0x00000040 (64)
rdInst_CastVolumetrixTranslucentShadow 0x00000080 (128)
rdInst_ReceivesDecals 0x00000100 (256)
rdInst_DisableCollision 0x00000200 (512)
rdInst_CanEverAffectNavigation 0x00000400 (1024)
rdInst_HasPerInstanceHitProxies 0x00000800 (2048)
rdInst_RayTracingFarField 0x00001000 (4096)
rdInst_AffectDynamicIndirectLighting 0x00002000 (8192)
rdInst_AffectDistanceFieldLighting 0x00004000 (16384)
rdInst_Selectable 0x00008000 (32768)
rdInst_ReceiveMobileCSMShadow 0x00010000 (65536)
rdInst_SelfShadowOnly 0x00020000 (131072)
rdInst_CastContactShadow 0x00040000 (262144)

rdBPtools has excellent tools for editing these settings, for single, bulk and instances – it’s well worth checking out.