I’m following this guide on SubObject replication, but I ran into this issue that I’m not understanding
The guide says to add the following to the Actor’s constructor
if(IsValid(MyActorSubobject))
{
RemoveReplicatedSubObject(MyActorSubobject);
}
MyActorSubobject = NewObject<UMyObject>();
MyActorSubobject->ReplicatedValue = 1;
// MyActorSubobject becomes a replicated subobject here
AddReplicatedSubObject(MyActorSubobject);
however it causes a null reference when calling AddReplicatedSubObject(MyActorSubobject)
My understanding of this code is that if the SubObject is valid, it removes it from the replicated subobject list before executing the rest
Then it creates an instance of the UMyObject subobject and assigns it to MyActorSubobject,
Finally it adds the newly assigned subobject to the replicated subobject list
How is there room for a null here?