diff --git a/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs b/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs index 6b3217d6f6fc3cfb2d7e8b3ca0b81f3b493b7b78..38f5d20a8895f034cc1a9dfa369d067e1d72495a 100644 --- a/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs +++ b/Source/DisplayClusterExtensions/DisplayClusterExtensions.Build.cs @@ -30,6 +30,7 @@ public class DisplayClusterExtensions : ModuleRules "DisplayCluster", "DisplayClusterInput", "Engine", + "HeadMountedDisplay", "InputCore" } ); diff --git a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp index c82bbab0cec6fee56372dde0274f1ec19ffe83fc..fc9d3e19a022ab700aa85d86d9e688238471ba74 100644 --- a/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp +++ b/Source/DisplayClusterExtensions/Private/DisplayClusterPawnCAVE.cpp @@ -7,6 +7,7 @@ #include "Input/IDisplayClusterInputManager.h" #include "Kismet/GameplayStatics.h" #include "DisplayClusterSettings.h" +#include "HeadMountedDisplayFunctionLibrary.h" #include "IDisplayCluster.h" ADisplayClusterPawnCAVE::ADisplayClusterPawnCAVE(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -21,6 +22,8 @@ ADisplayClusterPawnCAVE::ADisplayClusterPawnCAVE(const FObjectInitializer& Objec RotatingComponent->RotationRate = FRotator::ZeroRotator; TranslationDirection = RootComponent; + + AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events. } void ADisplayClusterPawnCAVE::OnForward_Implementation (float Value) @@ -87,6 +90,17 @@ void ADisplayClusterPawnCAVE::BeginPlay () MovementComponent->Deceleration = Settings->MovementDeceleration; MovementComponent->TurningBoost = Settings->MovementTurningBoost; BaseTurnRate = Settings->RotationSpeed ; + + if (UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled()) + { + LeftMotionControllerComponent = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("LeftMotionControllerComponent")); + LeftMotionControllerComponent->SetTrackingSource (EControllerHand::Left); + LeftMotionControllerComponent->SetShowDeviceModel(true); + + RightMotionControllerComponent = CreateDefaultSubobject<UMotionControllerComponent>(TEXT("RightMotionControllerComponent")); + RightMotionControllerComponent->SetTrackingSource (EControllerHand::Right); + RightMotionControllerComponent->SetShowDeviceModel(true); + } } void ADisplayClusterPawnCAVE::Tick (float DeltaSeconds) { diff --git a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h index e2e9b9e6ada2a5fc1b70c03d1a0429c02eb9f429..f2770555ee88126c0bad44951ea8b5375a012840 100644 --- a/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h +++ b/Source/DisplayClusterExtensions/Public/DisplayClusterPawnCAVE.h @@ -6,6 +6,7 @@ #include "CoreMinimal.h" #include "DisplayClusterPawn.h" #include "DisplayClusterSceneComponent.h" +#include "MotionControllerComponent.h" #include "DisplayClusterPawnCAVE.generated.h" @@ -35,6 +36,8 @@ protected: virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; virtual UPawnMovementComponent* GetMovementComponent () const override; - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UFloatingPawnMovement* MovementComponent = nullptr; - UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UFloatingPawnMovement* MovementComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* LeftMotionControllerComponent = nullptr; + UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UMotionControllerComponent* RightMotionControllerComponent = nullptr; };