Section 7.5. Saved Proxy States

Sometimes you’ll want to have actors that store their state when they swap back into instances or prefabs – for example, if you’re AI proxy has received damage during it’s Proxy stage, you want it to remember that the next time it swaps back into the Proxy.

The rdInst Proxy system has a great way to handle that – each Proxy can have a DataAsset assigned to it – and you have complete control over what you add to that DataAsset. When the Instance is swapped to the Proxy, it calls a LoadState Function that you can override, when it swaps back to the Instance, a SaveState Function is called.

To create your own DataAsset, firstly create a new Blueprint, Subclassed from rdStateDataAsset. In this Blueprint add variables to describe all the state information you require – you can also add helper functions in there.

Now create a new DataAsset and SubClass it from your new Blueprint Class:

That is now your State DataAsset. You can pass that into the “State” Pin of the AddProxy functions.

That leaves implementing the Load and Save events when the Proxy is swapped in and out, you can do that easily by overriding two functions in your Proxy Actor:

You have access to the Mesh/Index or Prefab in the events too, so you can do things like change per-instance custom data to reflect any changes in the proxy actor.


Tutorials