Reusing UE4 Actor* replication mechanism in custom struct or class?

LooFiiK
Mon, 15 Feb 2021 02:21:05 +0000
C++

Hello, I would like to ask if anybody knows how UE4 handles replication of Actor*.
I want to try to implement my own replication of Actor from a custom struct.*

For example.

Suppose I have Actor A and Actor
B and both are replicated.

A is spawned on server and he spawns B.

Then A will assign B pointer
to its custom struct’s property with
custom replication.

In “pseudocode”:

struct CustomStructType{
  Actor* pointer;
  ...custom replication of pointer code
}
class A{
  UPROPERTY(Replicated) // the syntax might be wrong but this is marked to be replicated so the custom replication code invokes
  CustomStructType customStruct;
}
A.customStruct.pointer = B;

Nothing in this struct is marked as UPROPERTY.

I need to wait for B to replicate to the client before the custom struct replicates, or before it deserialized on the client.

If the struct replicates first, then it will point to null since the actor does not exist yet on the client (if I am getting this right).

And I do not want to mark anything in the struct as UPROPERTY since this is only simplification of the problem to its minimal form.

(in reality the pointer is in a TMap which cannot replicate by default)

SInce UE already has a mechanism for waiting for its UPROPERTY marked properties which hold pointers to Actors →
I would like to leverage this mechanism.

Does anybody know how to do it, or where in the code could I find it?
I was trying to look for it, but cannot figure out where is the part that handles the waiting and where is the part of code that says this delayed serialization/deserialization will not work for Actor* that is not in a UPROPERTY

2 posts - 1 participant