From 61e4aa2e6a377525655713259aa5393a17f2ceea Mon Sep 17 00:00:00 2001 From: Mamadou Babaei Date: Thu, 23 Mar 2023 18:01:44 +0100 Subject: [PATCH] force the wrist tracker to track the right hand on init/begin/construct --- .../Private/SenseGlove/GameFramework/SGPawn.cpp | 10 +++++++++- .../SenseGlove/GameFramework/SGVirtualHandActor.cpp | 11 +++++++++++ .../Public/SenseGlove/GameFramework/SGPawn.h | 3 ++- .../SenseGlove/GameFramework/SGVirtualHandActor.h | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp index 22908382..641112a1 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGPawn.cpp @@ -141,6 +141,14 @@ void ASGPawn::BeginPlay() }); } +void ASGPawn::PreInitializeComponents() +{ + Super::PreInitializeComponents(); + + WristTrackerLeft->SetRight(HandLeft->IsRight()); + WristTrackerRight->SetRight(HandRight->IsRight()); +} + ASGPawn::FImpl::FImpl(ASGPawn* InOwner) : Owner(InOwner) { @@ -151,4 +159,4 @@ ASGPawn::FImpl::~FImpl() = default; void ASGPawn::FImplDeleter::operator()(const FImpl* P) const { delete P; -} \ No newline at end of file +} diff --git a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp index b03e00cb..dbf4d0d7 100644 --- a/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp +++ b/Source/SenseGlove/Private/SenseGlove/GameFramework/SGVirtualHandActor.cpp @@ -87,6 +87,8 @@ ASGVirtualHandActor::ASGVirtualHandActor(const FObjectInitializer& ObjectInitial WristTracker = CreateDefaultSubobject(TEXT("WristTracker")); WristTracker->SetupAttachment(RootComponent); + + WristTracker->SetRight(VirtualHand->IsRight()); } void ASGVirtualHandActor::BeginPlay() @@ -142,9 +144,18 @@ bool ASGVirtualHandActor::ShouldTickIfViewportsOnly() const return false; } +void ASGVirtualHandActor::PreInitializeComponents() +{ + Super::PreInitializeComponents(); + + WristTracker->SetRight(VirtualHand->IsRight()); +} + void ASGVirtualHandActor::OnConstruction(const FTransform& Transform) { Super::OnConstruction(Transform); + + WristTracker->SetRight(VirtualHand->IsRight()); } void ASGVirtualHandActor::EditorTick(float DeltaSeconds) diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h index 281454f8..5d05a688 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGPawn.h @@ -108,4 +108,5 @@ public: public: virtual void BeginPlay() override; -}; \ No newline at end of file + virtual void PreInitializeComponents() override; +}; diff --git a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h index c8097877..e34c76ce 100644 --- a/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h +++ b/Source/SenseGlove/Public/SenseGlove/GameFramework/SGVirtualHandActor.h @@ -101,6 +101,8 @@ public: virtual bool ShouldTickIfViewportsOnly() const override; + virtual void PreInitializeComponents() override; + virtual void OnConstruction(const FTransform& Transform) override; protected: