I’m trying to replicate a hierarchy of subobjects within a single actor and running into issues where the replicated subobjects outer is always the base AActor of the hierarchy since the replicated client subobject is constructed
inside UActorChannel::ReadContentBlockHeader line 2156 : SubObj = ConstructObject< UObject >( SubObjClass, Actor );
I don’t want my subobjects outer to be the actor but its direct component outer as it is on the server. If this is expected behavior than I may have to pass a reference to the component into the subchild and replicate that, but it seems quite odd that the outer pointer would ever be out of sync.
My type hierarchy:
Parent Actor MyActor
- MyComponent A with the following member
UPROPERTY(EditAnywhere, editinline, Replicated, Category = “Test”)
TArray<class UTestSubChild*> ReplicatedSubChildren;
UCLASS(BlueprintType, editinlinenew, ClassGroup = Test)
class UTestSubChild : public UObject
The instances of UTestSubChild are created at editor time and are serialized. The instance of MyActor is placed in the level and properly created on the server and then replicated, but the client versions of UTestSubChild are different as mentioned above.
For replicating the UTestSubChild and supporting RPC calls I followed my steps in the second post here:https://forums.unrealengine.com/showthread.php?29113-Components-and-component-children-required-components-etc
which I’ll repeat for clarity:
- Implement IsSupportedForNetworking in UTestSubChild
- Implement GetFunctionCallspace in UTestSubChild
- Implement CallRemoteFunction in UTestSubChild so RPCs are supported with the proper NetDriver for UTestSubChild
- Implement ReplicateSubobjects in Component A and loop over my array of UTestSubChild calling ReplicateSubObject on the passed in Actor Channel with each instance of UTestSubChild
- Implement GetLifetimeReplicatedProps in Component A and rep the respective array UTestSubChild
I really wish there was a solid overview of uobject replication outside the normal one-level actor and component relationship. I have outlined my issues and problems in a few different answerhub posts and the above forum post, but have yet to receive any responses.
The only available references on this topic are:
- The Comment in ActorChannel.h.
- The Generalized Subobject Replication section in the Outdated documentation at https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/Components/index.html
- This answerhub post: https://answers.unrealengine.com/questions/67620/getting-non-actor-subobject-replication-to-work.html
- and this related forum post https://forums.unrealengine.com/showthread.php?16831-Component-replication-need-some-help
It doesn’t look like I’ll be able to use editinlinenew as was used in UE3 for creating instances of types at editor time and having them replicated on the server. I really would just like this confirmed above all else.
I have reviewed the experimental AbilitySystem code and it appears their method of defining archetypes of a specific class or blueprint types and then instantiating that class/type at runtime may be a solution that could work with my desired type hierarchy, but I have my doubts.