From ad965acf04fad5e3020c4917a968f49711bf2ed0 Mon Sep 17 00:00:00 2001
From: David Gilbert <gilbert@vr.rwth-aachen.de>
Date: Wed, 20 Nov 2024 13:08:46 +0100
Subject: [PATCH] fix(pawn, cave): Tries to give each pawn a fixed name instead
 of generating a random one, as this leads to sync issues for some reason.

---
 .../RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp  | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp
index e2a15113..9102b160 100644
--- a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp
+++ b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp
@@ -143,6 +143,16 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer)
 			}
 		}
 
+		if (GetNetMode() == NM_Standalone)
+		{
+			const FName BaseName = PawnClass->HasAnyFlags(RF_ClassDefaultObject)
+				? PawnClass->GetFName()
+				: *PawnClass->GetFName().GetPlainNameString();
+
+			SpawnInfo.Name = BaseName;
+			SpawnInfo.NameMode = FActorSpawnParameters::ESpawnActorNameMode::Requested;
+		}
+
 		// Spawn and possess the pawn
 		APawn* ResultPawn = GetWorld()->SpawnActor<APawn>(PawnClass, StartSpot->GetTransform(), SpawnInfo);
 		NewPlayer->Possess(ResultPawn);
-- 
GitLab