# 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:** 1\
**Showing post:** 2

<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!

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-replicate-a-uobject-property-inside-a-struct/245642)._
