# How to replicate a UObject property inside a struct?

**URL:** <https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine\
**Created:** [August 15, 2021, 9:47pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642 "2021-08-15T21:47:20Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [August 15, 2021, 9:47pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/1 "2021-08-15T21:47:20Z")

</div>

Hi !

I’m discovering how to replicate UObject contained in AActor (following this post [Replicating UObjects: Building a Flexible Inventory System – James Baxter](https://jambax.co.uk/replicating-uobjects/)). My inventory system is a slot UObject contained in a UStruct itself contained in an ActorComponent. Something like that :

```auto
InventoryStruct =
{
    BackpackStruct = 
    {
         TArray<USlot> slotList,
    }
}

```

InventoryStruct is a UProperty of the InventoryComponent. Each slot have as Outer the InventoryComponent.

The struct is perfect to organize and initialize all slots (each substruct have an init function). Is there any way to do this UObject replication with the slot ?

Also based on what I found on the web, nobody agrees on the best way to make an inventory replicated… Some people say to make AActor item/slot to replicate them, other say that replicate high number of AActor isn’t a good idea for the network performance… Our game is survival multiplayer (like Ark), there will be potentially a ton of item in their inventory, what way would be optimal to reduce network usage ?

---

<div class="post-metadata">

**Author:** ![WilleyTheCutey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WilleyTheCutey](https://forums.unrealengine.com/u/WilleyTheCutey)\
**Post date:** [August 21, 2021, 7:37am UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/2 "2021-08-21T07:37:15Z")

</div>

Hey, I just solved almost the same problem as you are attempting to!

I think you can mark the InventoryStruct, BackpackStruct and slotList as replicated  
then in your ActorComponent’s ReplicateSubobjects()

```auto
// make sure to register your replicate vars in GetLifetimeReplicatedProps

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

    // this replicates the TArray
	bWroteSomething |= Channel->ReplicateSubobjectList(InventoryStruct.BackpackStruct.slotList, *Bunch, *RepFlags);

    // this replicates the actual TArray content
	for (auto* Slot : slotList)
	{
		bWroteSomething |= Channel->ReplicateSubobject(Slot, *Bunch, *RepFlags);
	}

	return bWroteSomething;
}

```

The code might have some syntax error or something since I am writing it top of my head.

Here is another good link :

> [@Replicating TArrays crashes game](https://forums.unrealengine.com/t/replicating-tarrays-crashes-game/21237/6):
>
> Okay so I finally successfully replicated a TArray of Objects, it is fairly simple once you get your head around Replication. Begin with defining the UObject you want replicated. I actually create a UNetworkObject as a base class for all UObjects I want replicated. But the quick and dirty way is to simply override the [IsSupportedForNetworking](https://docs.unrealengine.com/latest/INT/API/Runtime/CoreUObject/UObject/UObject/IsSupportedForNetworking/index.html) Then mark the properties you need replicated as UPROPERTY(Replicated) class UNetworkObject : UObject { virtual bool IsSupportedForNetworking() …

Hope it helps!

---

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [August 21, 2021, 2:59pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/3 "2021-08-21T14:59:32Z")

</div>

Thanks ! I finally abandoned the struct to be able to continue but I will see if it works.

---

<div class="post-metadata">

**Author:** ![Exelim](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Exelim](https://forums.unrealengine.com/u/Exelim)\
**Post date:** [January 30, 2025, 5:51pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/4 "2025-01-30T17:51:05Z")

</div>

Hello, I’ve tried to use approach you’ve mentioned but I faced a problem. For example I have Component and UObject\* member inside:  
UTestObject\* testObject;

Inside UTestObject I just have a simple field like this:  
UPROPERTY(Replicated)  
int m\_currentAmount = 0;

I also implemented both IsSupportedForNetworking and GetLifetimeReplicatedProps functions.

Then on both Server/Client in begin play I create testObject via NewObject. Then at somepoint of time I made an RPC call and change m\_currentAmount on Server and I don’t receive this update on client.  
However, if I change pointer itself, for example made something like this:  
testObject = nullptr;  
I will get an update on Client. Seems like it only replicates pointer by itself, but not the data inside pointer.  
Do you know how to fix this? Thanks

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [January 31, 2025, 12:47am UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/5 "2025-01-31T00:47:44Z")

</div>

did you add?

DOREPLIFETIME(UTestObject, m\_currentAmount);

---

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [February 11, 2025, 1:51am UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/6 "2025-02-11T01:51:09Z")

</div>

When you do replication, you only create object on the server. You are surely replicating only the pointer, not the object pointed.

So you are 2 distincts objets (client/server) but one pointer replicated. When you set null the pointer, the change is replicated, as expected.

The pointer and the object pointed are not the same thing.

PS : This post is old. You don’t need to replicate subobject like this anymore.

---

<div class="post-metadata">

**Author:** ![Auran131](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Auran131](https://forums.unrealengine.com/u/Auran131)\
**Post date:** [February 11, 2025, 5:23am UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/7 "2025-02-11T05:23:24Z")

</div>

> [@Alizia](#):
>
> PS : This post is old. You don’t need to replicate subobject like this anymore.

whats the new method?

---

<div class="post-metadata">

**Author:** ![Alizia](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alizia](https://forums.unrealengine.com/u/Alizia)\
**Post date:** [February 13, 2025, 5:47pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/8 "2025-02-13T17:47:38Z")

</div>

This way :

> **[Replicating UObjects in Unreal Engine | Unreal Engine 5.5 Documentation |...](https://dev.epicgames.com/documentation/en-us/unreal-engine/replicating-uobjects-in-unreal-engine)**
>
> Learn how to replicate UObjects in Unreal Engine.

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [October 20, 2026, 7:12pm UTC](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642/9 "2026-10-20T19:12:39Z")

</div>

structs cant carry subobject channels, so a UObject pointer inside a struct only replicates the pointer, never the object behind it. that is exactly what exelim hit here: setting the pointer to null replicates, changing m\_currentAmount inside doesnt, because there is no channel for the object itself.

the fix is to keep the array of slot objects directly on the inventory component, not inside the struct. outer each slot to the component, create them only on the server, mark the class IsSupportedForNetworking, register its vars with DOREPLIFETIME, and replicate each slot through ReplicateSubobjects on the component. keep the struct for layout or config if you like, but the replicated state lives on the objects.

you can also try Blueprint Object Replication, a UObject replication plugin for Unreal Engine that lets a component own blueprint item objects with replicated properties and notifies, so the struct nesting is not needed: [https://www.fab.com/listings/e26dcf07-7c78-4e67-8e56-272cf6df8021](https://www.fab.com/listings/e26dcf07-7c78-4e67-8e56-272cf6df8021)
