From 000834608e6cb14e76230f582fb22307f4762f95 Mon Sep 17 00:00:00 2001 From: David Gilbert <gilbert@vr.rwth-aachen.de> Date: Thu, 15 Aug 2024 16:07:13 +0200 Subject: [PATCH] fix(cave): Fixes player type issue in player spawning and DCRA attachment process for standalone Cave --- Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp | 6 +++++- .../Private/Pawn/ClusterRepresentationActor.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp index c9efeaf3..e2a15113 100644 --- a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp +++ b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp @@ -53,6 +53,9 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle else if (GetNetMode() == NM_Standalone && URWTHVRUtilities::IsRoomMountedMode()) { ClusterId = 0; + const EPlayerType Type = + URWTHVRUtilities::IsPrimaryNode() ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary; + State->RequestSetPlayerType(Type); } State->SetCorrespondingClusterId(ClusterId); } @@ -112,10 +115,11 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer) return; } + // When we're not in standalone: // If the new player is a secondary nDisplay node, spawn it only as a Spectator // Potentially we can use MustSpectate instead. UClass* PawnClass; - if (State->GetPlayerType() == EPlayerType::nDisplaySecondary) + if (GetNetMode() != NM_Standalone && State->GetPlayerType() == EPlayerType::nDisplaySecondary) { // For now, simply use the BP approach of spawning the pawn here. Can do this in a better way potentially. PawnClass = SpectatorClass; diff --git a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp index 2631be95..a280d911 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp @@ -128,7 +128,7 @@ bool AClusterRepresentationActor::AttachDCRA() } bool bAttached = DCRA->AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale); - UE_LOGFMT(Toolkit, Display, "Attaching DCRA {DCRA} to {this} returned {Res}", GetName(), DCRA->GetName(), + UE_LOGFMT(Toolkit, Display, "Attaching DCRA {DCRA} to {this} returned {Res}", DCRA->GetName(), GetName(), bAttached); DCRA->SetActorEnableCollision(false); -- GitLab