Skip to content
Snippets Groups Projects
Commit 0fa38996 authored by Ehret's avatar Ehret
Browse files

minor changes to make extraction of walking movement into a movement component work

parent cfd9e902
No related branches found
No related tags found
No related merge requests found
...@@ -27,9 +27,9 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial ...@@ -27,9 +27,9 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial
AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events. AutoPossessPlayer = EAutoReceiveInput::Player0; // Necessary for receiving motion controller events.
Movement = CreateDefaultSubobject<UWalkingPawnMovement>(TEXT("WalkingMovement")); WalkingMovement = CreateDefaultSubobject<UWalkingPawnMovement>(TEXT("WalkingMovement"));
Movement->SetUpdatedComponent(RootComponent); WalkingMovement->SetUpdatedComponent(RootComponent);
Movement->SetCameraComponent(CameraComponent); WalkingMovement->SetCameraComponent(CameraComponent);
RotatingMovement = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovement")); RotatingMovement = CreateDefaultSubobject<URotatingMovementComponent>(TEXT("RotatingMovement"));
RotatingMovement->UpdatedComponent = RootComponent; RotatingMovement->UpdatedComponent = RootComponent;
...@@ -210,10 +210,10 @@ void AVirtualRealityPawn::BeginPlay() ...@@ -210,10 +210,10 @@ void AVirtualRealityPawn::BeginPlay()
if (SettingsActors.Num() > 0) if (SettingsActors.Num() > 0)
{ {
ADisplayClusterSettings* Settings = Cast<ADisplayClusterSettings>(SettingsActors[0]); ADisplayClusterSettings* Settings = Cast<ADisplayClusterSettings>(SettingsActors[0]);
Movement->MaxSpeed = Settings->MovementMaxSpeed; WalkingMovement->MaxSpeed = Settings->MovementMaxSpeed;
Movement->Acceleration = Settings->MovementAcceleration; WalkingMovement->Acceleration = Settings->MovementAcceleration;
Movement->Deceleration = Settings->MovementDeceleration; WalkingMovement->Deceleration = Settings->MovementDeceleration;
Movement->TurningBoost = Settings->MovementTurningBoost; WalkingMovement->TurningBoost = Settings->MovementTurningBoost;
BaseTurnRate = Settings->RotationSpeed; BaseTurnRate = Settings->RotationSpeed;
} }
...@@ -277,6 +277,9 @@ void AVirtualRealityPawn::BeginPlay() ...@@ -277,6 +277,9 @@ void AVirtualRealityPawn::BeginPlay()
CollisionComponent->SetCollisionProfileName(FName("NoCollision")); CollisionComponent->SetCollisionProfileName(FName("NoCollision"));
CollisionComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision); CollisionComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
//if the navigation mode was changed in the editor, it should be updated in the actual movement component
SetNavigationMode(NavigationMode);
} }
void AVirtualRealityPawn::EndPlay(const EEndPlayReason::Type EndPlayReason) void AVirtualRealityPawn::EndPlay(const EEndPlayReason::Type EndPlayReason)
...@@ -417,7 +420,7 @@ FTwoVectors AVirtualRealityPawn::GetHandRay(float Length) ...@@ -417,7 +420,7 @@ FTwoVectors AVirtualRealityPawn::GetHandRay(float Length)
UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent() const UPawnMovementComponent* AVirtualRealityPawn::GetMovementComponent() const
{ {
return Movement; return WalkingMovement;
} }
void AVirtualRealityPawn::InitRoomMountedComponentReferences() void AVirtualRealityPawn::InitRoomMountedComponentReferences()
...@@ -457,5 +460,6 @@ void AVirtualRealityPawn::InitRoomMountedComponentReferences() ...@@ -457,5 +460,6 @@ void AVirtualRealityPawn::InitRoomMountedComponentReferences()
void AVirtualRealityPawn::SetNavigationMode(EVRNavigationModes Mode) void AVirtualRealityPawn::SetNavigationMode(EVRNavigationModes Mode)
{ {
Movement->NavigationMode = Mode; NavigationMode = Mode;
WalkingMovement->NavigationMode = Mode;
} }
...@@ -56,6 +56,8 @@ public: ...@@ -56,6 +56,8 @@ public:
UFUNCTION(Category = "Pawn") USceneComponent* GetTrackingOriginComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetTrackingOriginComponent();
UFUNCTION(Category = "Pawn") void SetNavigationMode(EVRNavigationModes Mode); UFUNCTION(Category = "Pawn") void SetNavigationMode(EVRNavigationModes Mode);
//we also add this property so the navigation mode can be changed easier in the editor, will get forwarded to the movment comp on BeginPlay
UPROPERTY(Category = "Pawn", EditAnywhere, BlueprintReadOnly) EVRNavigationModes NavigationMode = EVRNavigationModes::nav_mode_fly;
private: private:
UFUNCTION(Category = "Pawn") USceneComponent* GetCaveCenterComponent(); UFUNCTION(Category = "Pawn") USceneComponent* GetCaveCenterComponent();
...@@ -78,7 +80,7 @@ protected: ...@@ -78,7 +80,7 @@ protected:
virtual UPawnMovementComponent* GetMovementComponent() const override; virtual UPawnMovementComponent* GetMovementComponent() const override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn", meta = (AllowPrivateAccess = "true")) float BaseTurnRate = 45.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn", meta = (AllowPrivateAccess = "true")) float BaseTurnRate = 45.0f;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UWalkingPawnMovement* Movement = nullptr; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) UWalkingPawnMovement* WalkingMovement = nullptr;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingMovement = nullptr; UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn", meta = (AllowPrivateAccess = "true")) URotatingMovementComponent* RotatingMovement = nullptr;
// Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick. // Use only when handling cross-device (PC, HMD, CAVE/ROLV) compatibility manually. CAVE/ROLV flystick.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment