diff --git a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp index d182cbe6961c440a8ccd25b91e899ad99de61197..bd4a40004c017c5a1f5687a969d198affd2f0bb5 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp @@ -79,12 +79,17 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState* return; } + const auto CCA = PlayerState->GetCorrespondingClusterActor(); + + if (CCA == nullptr) // this can happen often if property isn't replicated yet, this is okay. + return; + UE_LOGFMT(Toolkit, Display, "{Name} AttachDCRAIfRequired: Player State is {PlayerState}, PlayerState->CCA is {CCA}.", GetName(), - PlayerState->GetName(), PlayerState->GetCorrespondingClusterActor()->GetName()); + PlayerState->GetName(), CCA->GetName()); // The local player this is executed on corresponds to this actor - if (PlayerState->GetCorrespondingClusterActor() == this) + if (CCA == this) { UE_LOGFMT(Toolkit, Display, "{Name} AttachDCRAIfRequired: Attaching DCRA to {Name}.", GetName());