Unreal Engine 5.1 ReplicateSubobjectList Not Working

I’m trying to use the new subobject replicate system,but it’s doesn’t work.

according to documentation (虚幻引擎中的复制子对象 | 虚幻引擎5.1文档)

In constructor

In BeginPlay

Call
fd524bba5beb3c0832a260a5cb67a10

engine crashed

I also try to Override IsSupportNetworking() in UObject derived class,return true.
engine stop crash,but RPC and Property replicate not work.

sorry for my poor English,if anyone can help me,really thanks

Raw UObjects can’t be replicated by default. For the first thing you can check your logic with AActor class as a base. upd: or just as a struct inside of a character

If it’s works fine (and i guess it is), and you really sure you need custom uobject replication then here is a kind of a guide:

Copypaste of code from related guide

Guide source (ru)
In short:

//myobject.h
// object itself
UCLASS(Blueprintable)
class MYPROPJECT_API UMyObject : public UObject
{
	GENERATED_BODY()
public:
	UMyObject();
	virtual bool IsSupportedForNetworking () const override { return true; };
	void GetLifetimeReplicatedProps (TArray<FLifetimeProperty>& OutLifetimeProps) override;

	UPROPERTY(Replicated, BlueprintReadWrite, Category="Object")
	int MyInteger;
}

//myobject.cpp
UMyObject ::UMyObject ()
{
	bReplicates = true;
}
void UMyObject ::GetLifetimeReplicatedProps (TArray<FLifetimeProperty>& OutLifetimeProps)
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	DOREPLIFETIME(UMyObject, MyInteger);
}

//myactor.h
// replicateable owner of your object
class MYPROPJECT_API AMyActor : public AActor
{
	GENERATED_BODY()

public:

	AMyActor();

	virtual bool ReplicateSubobjects (class UActorChannel *Channel, class FOutBunch *Bunch, FReplicationFlags *RepFlags) override;

	void GetLifetimeReplicatedProps (TArray<FLifetimeProperty>& OutLifetimeProps) const override;

	virtual void BeginPlay ();

	UPROPERTY(Replicated, BlueprintReadOnly, Category="Object")
	class UMyObject* MyObject;
}

//myactor.cpp
#include "MyActor.h"
#include "Net/UnrealNetwork.h"
#include "Engine/World.h"
#include "Engine/ActorChannel.h"
#include "PATH_TO_YOUR_UObject/MyObject.h"

AMyActor::AMyActor()
{
	bReplicates = true;
}

void AMyActor::GetLifetimeReplicatedProps (TArray<FLifetimeProperty>& OutLifetimeProps)
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

 
	DOREPLIFETIME(AMyActor, MyObject);
}

bool AMyActor::ReplicateSubobjects(UActorChannel * Channel, FOutBunch * Bunch, FReplicationFlags * RepFlags)
{
	bool WroteSomething = Super::ReplicateSubobjects(Channel, Bunch, RepFlags);

	if (MyObject ) WroteSomething |= Channel->ReplicateSubobject(MyObject , *Bunch, *RepFlags);

	return WroteSomething;
}

AMyActor::BeginPlay()
{
	if(HasAuthority()) 
	{
	MyObject = NewObject<UMyObject>(this);
	if(MyObject) UE_LOG(LogTemp, Log, TEXT("%s created"), *MyObject->GetName());
	}
}

But realistically there is a chances there are already a place in engine for handling data you need, like GameState, PlayerState, etc. I suggest checking this guide first before diving into custom uobjects.

Fyi in my project i’m also started from custom uobjects, but after all 95% of code was moved back into engine-provided classes

Thanks,that’s work.recently I use this method to implement uobject replicate,but UE5.1 add a new system"Subobject Replicate List" according to document,they say you no longer to need override some functions to implement UObject replicate;you can directly use built-in system to replicate uobject derived class.but the new system not work for me.sad thing is,your method will DEPRECATED at next engine update.

sorry for my poor English

UE5.1 add a new system

oh, i’m still on 5.0.3 and seems i’m out of the loop, sorry then. Will read about it later

Solved,I just need Add UPROPERTY(Replicated) Specifier.like property rep