diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp index 87e52d26..450d049b 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGVirtualHandComponent.cpp @@ -368,16 +368,15 @@ bool USGVirtualHandComponent::GetMotionControllerData(FXRMotionControllerData& O { OutMotionControllerData.bValid = false; - if (GEngine) + IXRTrackingSystem* XRTrackingSystem{GEngine ? GEngine->XRSystem.Get() : nullptr}; + if (!XRTrackingSystem) { - IXRTrackingSystem* XrtTrackingSystem{GEngine->XRSystem.Get()}; - if (XrtTrackingSystem) - { - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - XrtTrackingSystem->GetMotionControllerData(this, Hand, OutMotionControllerData); - } + return false; } + const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; + XRTrackingSystem->GetMotionControllerData(this, Hand, OutMotionControllerData); + return OutMotionControllerData.bValid; } diff --git a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp index 8fae43ca..2a125179 100644 --- a/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp +++ b/Source/SenseGlove/Private/SenseGlove/Components/SGWristTrackerComponent.cpp @@ -184,16 +184,15 @@ bool USGWristTrackerComponent::GetMotionControllerData(FXRMotionControllerData& { OutMotionControllerData.bValid = false; - if (GEngine) + IXRTrackingSystem* XRTrackingSystem{GEngine ? GEngine->XRSystem.Get() : nullptr}; + if (!XRTrackingSystem) { - IXRTrackingSystem* XrtTrackingSystem{GEngine->XRSystem.Get()}; - if (XrtTrackingSystem) - { - const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; - XrtTrackingSystem->GetMotionControllerData(this, Hand, OutMotionControllerData); - } + return false; } + const EControllerHand Hand = IsRight() ? EControllerHand::Right : EControllerHand::Left; + XRTrackingSystem->GetMotionControllerData(this, Hand, OutMotionControllerData); + return OutMotionControllerData.bValid; }