# Property not getting replicated C++

**URL:** <https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509>\
**Category:** Multiplayer & Networking\
**Tags:** Networking, Replication, unreal-engine, CPP, question\
**Created:** [January 20, 2017, 10:47pm UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509 "2017-01-20T22:47:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_0ba2eb3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0ba2eb3c](https://forums.unrealengine.com/u/anonymous_user_0ba2eb3c)\
**Post date:** [January 20, 2017, 10:47pm UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/1 "2017-01-20T22:47:54Z")

</div>

I have an actor component that is called `Inventory.h` that has a variable `TArray inventory;` that is not getting replicated.

Here’s my `GetLifetimeReplicatedProps` at `Inventory.cpp`

```
void UInventory::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

	// Replicate to everyone
	DOREPLIFETIME(UInventory, inventory);
	DOREPLIFETIME(UInventory, equippedItems);
	DOREPLIFETIME(UInventory, weaponsInInv);
	DOREPLIFETIME(UInventory, equippedItemSelected);

}

```

When I change the variable inventory ON THE SERVER the client doesn’t get the modifications. I don’t know if I did something wrong or if I need to create a RPC call from the server to the owning client to send the variable value.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Dartanlla](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dartanlla/32/724052_2.png) [@Dartanlla](https://forums.unrealengine.com/u/Dartanlla)\
**Post date:** [January 21, 2017, 3:43am UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/2 "2017-01-21T03:43:21Z")

</div>

I am going to guess that since your object UInventory starts with a U that you are inheriting from a UObject. If so, there is your problem. According to the UE4 docs, Actors replicate, but UObjects do not:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

If you are using an Actor and not a UObject and it still does not work, make sure you are also properly marking the individual properties that you want to replicate with:

UPROPERTY(Replicated)

And of course make sure that you set bReplicates = true; in your constructor.

---

<div class="post-metadata">

**Author:** ![Dartanlla](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dartanlla/32/724052_2.png) [@Dartanlla](https://forums.unrealengine.com/u/Dartanlla)\
**Post date:** [January 21, 2017, 3:45am UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/3 "2017-01-21T03:45:58Z")

</div>

I missed the part where you said your UObject was an actor component.

Did you add this to your actor component?

```
virtual bool IsSupportedForNetworking() const override
    {
        return true;
    }

```

See this section for more code you have to add to get subobjects to replicate:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0ba2eb3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0ba2eb3c](https://forums.unrealengine.com/u/anonymous_user_0ba2eb3c)\
**Post date:** [January 21, 2017, 4:10am UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/4 "2017-01-21T04:10:54Z")

</div>

Thank you so much. I THINK my problem is solved… The only problem now is that I get these errors when compiling:

```
CompilerResultsLog:Error: Error C:\Users\GAME\ShooterGame\Source\ShooterGame\ShooterGameCharacter.cpp(84) : error C2275: 'AShooterGameCharacter': illegal use of this type as an expression
CompilerResultsLog:Error: Error C:\Users\GAME\ShooterGame\Source\ShooterGame\ShooterGameCharacter.cpp(84) : error C3861: 'DOREPLIFETIME': identifier not found

```

The errors are in my character class (which has the UInventory component) and refers to

```
void AShooterGameCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);

    //I guess I can't use AShooterGameCharacter as a type here...
	DOREPLIFETIME(AShooterGameCharacter, inventoryActor);
}

```

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_0ba2eb3c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_0ba2eb3c](https://forums.unrealengine.com/u/anonymous_user_0ba2eb3c)\
**Post date:** [January 21, 2017, 4:13am UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/5 "2017-01-21T04:13:05Z")

</div>

Whoops sorry, solved it haha. I used  
#include “Networking.h”

instead of  
#include “UnrealNetwork.h”

---

<div class="post-metadata">

**Author:** ![Dartanlla](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dartanlla/32/724052_2.png) [@Dartanlla](https://forums.unrealengine.com/u/Dartanlla)\
**Post date:** [January 21, 2017, 4:14am UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/6 "2017-01-21T04:14:27Z")

</div>

Yep, I was just about to say that exact thing. That error gets me all the time 🙂

---

<div class="post-metadata">

**Author:** ![duke22](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@duke22](https://forums.unrealengine.com/u/duke22)\
**Post date:** [October 16, 2017, 2:57pm UTC](https://forums.unrealengine.com/t/property-not-getting-replicated-c/382509/7 "2017-10-16T14:57:08Z")

</div>

Did this solve the problem?
