From 27e6d4f11758e7228fedf1b334a98711e4d34c2f Mon Sep 17 00:00:00 2001 From: David Gilbert <gilbert@vr.rwth-aachen.de> Date: Tue, 6 Aug 2024 15:39:01 +0200 Subject: [PATCH] fix(cave): Fixes crash when playing normally in desktop --- Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index 5c27dac2..90f6d25b 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -78,7 +78,7 @@ void ARWTHVRPawn::NotifyControllerChanged() // Only cluster types are valid here as they are set on connection. // For all other player types this is a race condition - if (Type == EPlayerType::nDisplayPrimary || GetNetMode() == NM_Standalone) + if (Type == EPlayerType::nDisplayPrimary || Type == EPlayerType::nDisplaySecondary) { UE_LOGFMT(Toolkit, Display, "ARWTHVRPawn: Attaching Cluster to Pawn {Pawn}.", GetName()); AttachClustertoPawn(); @@ -266,14 +266,17 @@ void ARWTHVRPawn::AttachClustertoPawn() if (const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>()) { - if (!State->GetCorrespondingClusterActor()) + const auto ClusterActor = State->GetCorrespondingClusterActor(); + if (!ClusterActor) + { UE_LOGFMT( Toolkit, Error, "ARWTHVRPawn::AttachClustertoPawn: GetCorrespondingClusterActor returned null! This won't work on " "the Cave."); - + return; + } const FAttachmentTransformRules AttachmentRules = FAttachmentTransformRules::SnapToTargetNotIncludingScale; - bool bAttached = State->GetCorrespondingClusterActor()->AttachToComponent(GetRootComponent(), AttachmentRules); + bool bAttached = ClusterActor->AttachToComponent(GetRootComponent(), AttachmentRules); // State->GetCorrespondingClusterActor()->OnAttached(); UE_LOGFMT(Toolkit, Display, "ARWTHVRPawn: Attaching corresponding cluster actor to our pawn returned: {Attached}", bAttached); -- GitLab