Replication of TScriptInterface C++
I have problems with getting my interface to replicate. I have a BaseItemInterface and different Items that implements the interface. I try to replicate the interface something like this:
TScriptInterface< BaseItemInterface > MyInterface;
It doesnt work.
But when I replicate my raw Item class, ex. ToolItem
It works for that object.
Can UE4 handle Interface objects Replication or do I need to add some more code anywhere? I've done the bReplicates = true & DOREPLIFETIME(YOUR_CLASS_NAME, PropName); thingy according to https://wiki.unrealengine.com/Networking/Replication
TScriptInterface<..> does not currently get replicated by UE4. I actually think it should give an error when you try to do it, but it just silently fails.
Anyway, TScriptInterface<..> is basically just two things, a pointer to your UObject, and then a cached pointer to the Interface part of your UObject that you're interested in.
The way I would do it right now, given the current limitations, would be to replicate a regular UObject or AActor pointer as a private property, and give access to getting/setting it through public members which only allow TScriptInterface<..> as the argument. The getter would cast from the UObject property to the interface that you want. Enforcing it this way would reduce the chances that a mistake is made elsewhere in the code.
Follow this question
Once you sign in you will be able to subscribe for any updates here