# Property Replication Crash

**URL:** <https://forums.unrealengine.com/t/property-replication-crash/667510>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, CPP, question\
**Created:** [October 11, 2022, 9:34pm UTC](https://forums.unrealengine.com/t/property-replication-crash/667510 "2022-10-11T21:34:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Facer144](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Facer144](https://forums.unrealengine.com/u/Facer144)\
**Post date:** [October 11, 2022, 9:34pm UTC](https://forums.unrealengine.com/t/property-replication-crash/667510/1 "2022-10-11T21:34:20Z")

</div>

**My objective:**

1. I’ve created a custom AGameState subclass. I want some of the variables to be replicated between the clients so I use the following macro on every variable I want to be replicated:

> UPROPERTY(Replicated)

1. Doing so requires to have a well known function to assist with the replication:

> GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const;

1. And Inside that function I call the parent function and use following macro:

> DOREPLIFETIME(ACustomGameState, MyReplicatedVariable);

I don’t think I’m missing anything, if I am please let me know.

**The problem:**

Every time I run the game with a replicated variable (with the UPROPERTY(Replicated) macro and the DOREPLIFETIME(ACustomGameState, MyReplicatedVariable) macro) the game crashes.

What catched my eye in the log was this message (full log is below):

> Assertion failed: bIsValid [File:PATH\_TO\_FILE\CustomGameState.gen.cpp] [Line: 333] UHT Generated Rep Indices do not match runtime populated Rep Indices for properties in ACustomGameState.

I’ve searched across the internet for the meaning of this message with no success in finding anything closely related to this.

I would apreciate any help.

> **The log:**
>
> > Assertion failed: bIsValid [File:D:\Github\Warper\Intermediate\Build\Win64\UnrealEditor\Inc\Warper\WarperGameState.gen.cpp] [Line: 333] UHT Generated Rep Indices do not match runtime populated Rep Indices for properties in AWarperGameState
> > 
> > UnrealEditor\_Warper\_patch\_0!AWarperGameState::ValidateGeneratedRepEnums() [D:\Github\Warper\Intermediate\Build\Win64\UnrealEditor\Inc\Warper\WarperGameState.gen.cpp:333]  
> > UnrealEditor\_CoreUObject!UClass::SetUpRuntimeReplicationData() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\Class.cpp:4371]  
> > UnrealEditor\_Engine!FRepLayout::InitFromClass() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\RepLayout.cpp:5941]  
> > UnrealEditor\_Engine!FRepLayout::CreateFromClass() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\RepLayout.cpp:5916]  
> > UnrealEditor\_Engine!UNetDriver::GetObjectClassRepLayout() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:5980]  
> > UnrealEditor\_Engine!UNetDriver::FindOrCreateRepChangedPropertyTracker() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:5965]  
> > UnrealEditor\_Engine!AActor::CallPreReplication() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Actor.cpp:1454]  
> > UnrealEditor\_Engine!UNetDriver::ServerReplicateActors\_BuildConsiderList() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:4371]  
> > UnrealEditor\_Engine!UNetDriver::ServerReplicateActors() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:5079]  
> > UnrealEditor\_Engine!UNetDriver::TickFlush() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\NetDriver.cpp:705]  
> > UnrealEditor\_Engine!TBaseUObjectMethodDelegateInstance\<0,UNetDriver,void \_\_cdecl(float),FDefaultDelegateUserPolicy\>::ExecuteIfSafe() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:611]  
> > UnrealEditor\_Engine!TMulticastDelegate\<void \_\_cdecl(float),FDefaultDelegateUserPolicy\>::Broadcast() [D:\build++UE5\Sync\Engine\Source\Runtime\Core\Public\Delegates\DelegateSignatureImpl.inl:967]  
> > UnrealEditor\_Engine!UWorld::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\LevelTick.cpp:1695]  
> > UnrealEditor\_UnrealEd!UEditorEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\EditorEngine.cpp:1777]  
> > UnrealEditor\_UnrealEd!UUnrealEdEngine::Tick() [D:\build++UE5\Sync\Engine\Source\Editor\UnrealEd\Private\UnrealEdEngine.cpp:474]  
> > UnrealEditor!FEngineLoop::Tick() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:5215]  
> > UnrealEditor!GuardedMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:183]  
> > UnrealEditor!GuardedMainWrapper() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:147]  
> > UnrealEditor!LaunchWindowsStartup() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:283]  
> > UnrealEditor!WinMain() [D:\build++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:330]  
> > UnrealEditor!\_\_scrt\_common\_main\_seh() [d:\a01\_work\6\s\src\vctools\crt\vcstartup\src\startup\exe\_common.inl:288]  
> > kernel32  
> > ntdll

> **The GetLifetimeReplicatedProps Function**
>
> void AWarperGameState::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const  
> {  
> Super::GetLifetimeReplicatedProps(OutLifetimeProps);
> 
> ```
> DOREPLIFETIME(AWarperGameState, RoundState);
> DOREPLIFETIME(AWarperGameState, GameTimer);
> DOREPLIFETIME(AWarperGameState, AgentsScore);
> DOREPLIFETIME(AWarperGameState, WarpersScore);
> DOREPLIFETIME(AWarperGameState, Agents);
> DOREPLIFETIME(AWarperGameState, Warpers);
> DOREPLIFETIME(AWarperGameState, Spectators);
> 
> ```
> 
> }

> **Some replicated variables**
>
> ```
> UPROPERTY(Replicated)
> TEnumAsByte<ERoundState> RoundState;
> 
> UPROPERTY(Replicated)
> FTimerHandle GameTimer;
> 
> UPROPERTY(Replicated)
> int AgentsScore;
> UPROPERTY(Replicated)
> int WarpersScore;
> 
> UPROPERTY(Replicated)
> TArray<AWarperPlayerState*> Agents;
> 
> ```

> **Constructor**
>
> AWarperGameState::AWarperGameState(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)  
> {
> 
> > ```
> > // Comented this to see if it made a diference. It didn't...
> > 
> > ```
> > 
> > // bReplicates = true;  
> > // NetUpdateFrequency = 16;  
> > // MinNetUpdateFrequency = 2;
> > 
> > AgentsScore = 0;  
> > WarpersScore = 0;  
> > RoundState = MatchNotStarted;  
> > }

---

<div class="post-metadata">

**Author:** ![astro\_coder](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@astro\_coder](https://forums.unrealengine.com/u/astro_coder)\
**Post date:** [January 20, 2023, 4:33pm UTC](https://forums.unrealengine.com/t/property-replication-crash/667510/2 "2023-01-20T16:33:03Z")

</div>

I believe it is due to trying to replicate the TArray. I’ve run into the same issue with TMap. As a workaround, try creating a struct to hold your array. See [TMap replication still not supported? - #10 by spacebares](https://forums.unrealengine.com/t/tmap-replication-still-not-supported/348884/10)  
[Replicating TArrays crashes game - #3 by ArcainOne](https://forums.unrealengine.com/t/replicating-tarrays-crashes-game/21237/3)

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [January 20, 2023, 4:53pm UTC](https://forums.unrealengine.com/t/property-replication-crash/667510/3 "2023-01-20T16:53:05Z")

</div>

> [@Facer144](#):
>
> ACustomGameState

@Facer144 If you are trying to replicate a class derived from GameState then there is not need for replication as it is already shared information.

 ![state](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/d/8/dd8f998fa4441cf1a767655dba30e00e6c4768db.png)  
_Diagram from UE4\_Network\_Compendium\_by\_Cedric\_eXi\_Neukirchen.pdf_

Inside of GameStateBase you have

```auto
/** GameState is used to replicate game state relevant properties to all clients. */
	UPROPERTY(Transient)
	TObjectPtr<AGameStateBase> GameState;

```

Changing the GameState class to you custom class in your game mode should handle the replication logic.
