From 4ecfebe3813843f03d41ac3ac2cef4a12a9101e3 Mon Sep 17 00:00:00 2001 From: Christian Helwig <helwig@vr.rwth-aachen.de> Date: Fri, 19 Jan 2024 11:00:52 +0100 Subject: [PATCH] Feature(pawn, movement): Exposed PlayerInputComponent; Exposed SetupPlayerInput to BPs. --- Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp | 8 ++++++++ .../Public/Pawn/Navigation/MovementComponentBase.h | 1 + Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index 6e88a3cb..da433a26 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -93,6 +93,8 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen { Super::SetupPlayerInputComponent(PlayerInputComponent); + ThisPlayerInputComponent = PlayerInputComponent; + APlayerController* PlayerController = Cast<APlayerController>(GetController()); if (!PlayerController) { @@ -145,6 +147,12 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen } } +UInputComponent* ARWTHVRPawn::GetPlayerInputComponent() +{ + return ThisPlayerInputComponent; +} + + void ARWTHVRPawn::AddInputMappingContext(const APlayerController* PC, const UInputMappingContext* Context) const { if (Context) diff --git a/Source/RWTHVRToolkit/Public/Pawn/Navigation/MovementComponentBase.h b/Source/RWTHVRToolkit/Public/Pawn/Navigation/MovementComponentBase.h index f9d03b51..ef8548c7 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/Navigation/MovementComponentBase.h +++ b/Source/RWTHVRToolkit/Public/Pawn/Navigation/MovementComponentBase.h @@ -19,6 +19,7 @@ class RWTHVRTOOLKIT_API UMovementComponentBase : public UActorComponent, public public: // Already sets up VRPawn and InputSubsystem properties that can be used by child classes. + UFUNCTION(BlueprintCallable) virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override; protected: diff --git a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h index ca774d37..d9a6200a 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h +++ b/Source/RWTHVRToolkit/Public/Pawn/RWTHVRPawn.h @@ -87,6 +87,9 @@ protected: virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; void AddInputMappingContext(const APlayerController* PC, const UInputMappingContext* Context) const; + UFUNCTION(BlueprintCallable) + UInputComponent* GetPlayerInputComponent(); + /* LiveLink helper function called on tick */ void EvaluateLivelink() const; @@ -109,4 +112,8 @@ protected: /* Set device specific motion controller sources (None, L/R, Livelink) */ void SetupMotionControllerSources(); + +private: + + UInputComponent* ThisPlayerInputComponent; }; -- GitLab