Skip to content
Snippets Groups Projects
Commit 98341083 authored by Jonathan Ehret's avatar Jonathan Ehret
Browse files

extract rotation movement to reduce code dublication

#609
parent 56c0f205
No related branches found
No related tags found
1 merge request!33extract rotation movement to reduce code duplication
Showing
with 274 additions and 322 deletions
No preview for this file type
File added
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -14,13 +14,15 @@ void UContinuousMovementComponent::BeginPlay()
{
Super::BeginPlay();
VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
SetupInputActions();
}
void UContinuousMovementComponent::SetupInputActions()
{
Super::SetupInputActions();
const AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
// simple way of changing the handedness
if(bMoveWithRightHand)
{
......@@ -54,52 +56,12 @@ void UContinuousMovementComponent::SetupInputActions()
// walking
EI->BindAction(Move, ETriggerEvent::Triggered, this, &UContinuousMovementComponent::OnBeginMove);
// turning
if(bAllowTurning)
{
// no snap turning for desktop mode
if(bSnapTurn && !UVirtualRealityUtilities::IsDesktopMode())
{
EI->BindAction(Turn, ETriggerEvent::Started, this, &UContinuousMovementComponent::OnBeginSnapTurn);
} else
{
EI->BindAction(Turn, ETriggerEvent::Triggered, this, &UContinuousMovementComponent::OnBeginTurn);
}
}
// bind additional functions for desktop rotations
if (UVirtualRealityUtilities::IsDesktopMode())
{
APlayerController* PC = Cast<APlayerController>(VRPawn->GetController());
if (PC)
{
PC->bShowMouseCursor = true;
PC->bEnableClickEvents = true;
PC->bEnableMouseOverEvents = true;
} else
{
UE_LOG(LogTemp,Error,TEXT("PC Player Controller is invalid"));
}
EI->BindAction(DesktopRotation, ETriggerEvent::Started, this, &UContinuousMovementComponent::StartDesktopRotation);
EI->BindAction(DesktopRotation, ETriggerEvent::Completed, this, &UContinuousMovementComponent::EndDesktopRotation);
EI->BindAction(MoveUp, ETriggerEvent::Triggered,this,&UContinuousMovementComponent::OnBeginUp);
}
}
void UContinuousMovementComponent::StartDesktopRotation()
{
bApplyDesktopRotation = true;
}
void UContinuousMovementComponent::EndDesktopRotation()
{
bApplyDesktopRotation = false;
// turning is defined in MovementComponentBase
}
void UContinuousMovementComponent::OnBeginMove(const FInputActionValue& Value)
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
const bool bGazeDirected = UVirtualRealityUtilities::IsDesktopMode() || SteeringMode == EVRSteeringModes::STEER_GAZE_DIRECTED;
const FVector ForwardDir = bGazeDirected ? VRPawn->Head->GetForwardVector() : MovementHand->GetForwardVector();
......@@ -123,69 +85,9 @@ void UContinuousMovementComponent::OnBeginMove(const FInputActionValue& Value)
}
}
void UContinuousMovementComponent::OnBeginTurn(const FInputActionValue& Value)
{
if(UVirtualRealityUtilities::IsDesktopMode() && !bApplyDesktopRotation) return;
if (VRPawn->Controller != nullptr)
{
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X != 0.f)
{
VRPawn->AddControllerYawInput(TurnRateFactor * TurnValue.X);
if (UVirtualRealityUtilities::IsDesktopMode())
{
UpdateRightHandForDesktopInteraction();
}
}
if (TurnValue.Y != 0.f)
{
if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation)
{
VRPawn->AddControllerPitchInput(TurnRateFactor * -TurnValue.Y);
SetCameraOffset();
}
}
}
}
void UContinuousMovementComponent::OnBeginSnapTurn(const FInputActionValue& Value)
{
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X > 0.f)
{
VRPawn->AddControllerYawInput(SnapTurnAngle);
} else if (TurnValue.X < 0.f)
{
VRPawn->AddControllerYawInput(-SnapTurnAngle);
}
}
void UContinuousMovementComponent::SetCameraOffset() const
{
// this also incorporates the BaseEyeHeight, if set as static offset,
// rotations are still around the center of the pawn (on the floor), so pitch rotations look weird
FVector Location;
FRotator Rotation;
VRPawn->GetActorEyesViewPoint(Location, Rotation);
VRPawn->CameraComponent->SetWorldLocationAndRotation(Location, Rotation);
}
void UContinuousMovementComponent::UpdateRightHandForDesktopInteraction()
{
APlayerController* PC = Cast<APlayerController>(VRPawn->GetController());
if (PC)
{
FVector MouseLocation, MouseDirection;
PC->DeprojectMousePositionToWorld(MouseLocation, MouseDirection);
FRotator HandOrientation = MouseDirection.ToOrientationRotator();
VRPawn->RightHand->SetWorldRotation(HandOrientation);
}
}
void UContinuousMovementComponent::OnBeginUp(const FInputActionValue& Value)
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
const float MoveValue = Value.Get<FVector2D>().X;
//the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position
VRPawn->AddMovementInput(FVector::UpVector, MoveValue);
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "Pawn/MovementComponentBase.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h"
#include "Pawn/VirtualRealityPawn.h"
#include "Pawn/VRPawnInputConfig.h"
#include "Utility/VirtualRealityUtilities.h"
// Sets default values for this component's properties
UMovementComponentBase::UMovementComponentBase()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
}
void UMovementComponentBase::BeginPlay()
{
Super::BeginPlay();
SetupInputActions();
}
// Called every frame
void UMovementComponentBase::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (UVirtualRealityUtilities::IsDesktopMode())
{
UpdateRightHandForDesktopInteraction();
}
}
void UMovementComponentBase::SetupInputActions()
{
const AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
const APlayerController* PlayerController = Cast<APlayerController>(VRPawn->GetController());
UEnhancedInputLocalPlayerSubsystem* InputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());
if(!InputSubsystem)
{
UE_LOG(Toolkit,Error,TEXT("InputSubsystem IS NOT VALID"));
return;
}
// add Input Mapping context
InputSubsystem->AddMappingContext(IMCRotation,0);
UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(VRPawn->InputComponent);
if(!EI)
{
UE_LOG(Toolkit,Error,TEXT("Cannot cast Input Component to Enhanced Inpu Component in VRPawnMovement"));
return;
}
// turning
if(bAllowTurning)
{
// no snap turning for desktop mode
if(bSnapTurn && !UVirtualRealityUtilities::IsDesktopMode())
{
EI->BindAction(Turn, ETriggerEvent::Started, this, &UMovementComponentBase::OnBeginSnapTurn);
} else
{
EI->BindAction(Turn, ETriggerEvent::Triggered, this, &UMovementComponentBase::OnBeginTurn);
}
}
// bind additional functions for desktop rotations
if (UVirtualRealityUtilities::IsDesktopMode())
{
if (APlayerController* PC = Cast<APlayerController>(VRPawn->GetController()))
{
PC->bShowMouseCursor = true;
PC->bEnableClickEvents = true;
PC->bEnableMouseOverEvents = true;
} else
{
UE_LOG(LogTemp,Error,TEXT("PC Player Controller is invalid"));
}
EI->BindAction(DesktopRotation, ETriggerEvent::Started, this, &UMovementComponentBase::StartDesktopRotation);
EI->BindAction(DesktopRotation, ETriggerEvent::Completed, this, &UMovementComponentBase::EndDesktopRotation);
}
}
void UMovementComponentBase::StartDesktopRotation()
{
bApplyDesktopRotation = true;
}
void UMovementComponentBase::EndDesktopRotation()
{
bApplyDesktopRotation = false;
}
void UMovementComponentBase::OnBeginTurn(const FInputActionValue& Value)
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
if(UVirtualRealityUtilities::IsDesktopMode() && !bApplyDesktopRotation) return;
if (VRPawn->Controller != nullptr)
{
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X != 0.f)
{
VRPawn->AddControllerYawInput(TurnRateFactor * TurnValue.X);
if (UVirtualRealityUtilities::IsDesktopMode())
{
UpdateRightHandForDesktopInteraction();
}
}
if (TurnValue.Y != 0.f)
{
if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation)
{
VRPawn->AddControllerPitchInput(TurnRateFactor * -TurnValue.Y);
SetCameraOffset();
}
}
}
}
void UMovementComponentBase::OnBeginSnapTurn(const FInputActionValue& Value)
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X > 0.f)
{
VRPawn->AddControllerYawInput(SnapTurnAngle);
} else if (TurnValue.X < 0.f)
{
VRPawn->AddControllerYawInput(-SnapTurnAngle);
}
}
void UMovementComponentBase::SetCameraOffset() const
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
// this also incorporates the BaseEyeHeight, if set as static offset,
// rotations are still around the center of the pawn (on the floor), so pitch rotations look weird
FVector Location;
FRotator Rotation;
VRPawn->GetActorEyesViewPoint(Location, Rotation);
VRPawn->CameraComponent->SetWorldLocationAndRotation(Location, Rotation);
}
void UMovementComponentBase::UpdateRightHandForDesktopInteraction() const
{
AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
APlayerController* PC = Cast<APlayerController>(VRPawn->GetController());
if (PC)
{
FVector MouseLocation, MouseDirection;
PC->DeprojectMousePositionToWorld(MouseLocation, MouseDirection);
const FRotator HandOrientation = MouseDirection.ToOrientationRotator();
VRPawn->RightHand->SetWorldRotation(HandOrientation);
}
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MovementComponentBase.generated.h"
/**
*
*/
UCLASS(Blueprintable)
class RWTHVRTOOLKIT_API UMovementComponentBase : public UActorComponent
{
GENERATED_BODY()
public:
UMovementComponentBase();
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
bool bAllowTurning = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "bAllowTurning"))
bool bSnapTurn = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "!bSnapTurn && bAllowTurning"))
float TurnRateFactor = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "bSnapTurn && bAllowTurning", ClampMin = 0, ClampMax = 360))
float SnapTurnAngle = 22.5;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* Turn;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* DesktopRotation;
/*Movement Input*/
UFUNCTION(BlueprintCallable)
void OnBeginTurn(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginSnapTurn(const FInputActionValue& Value);
/*Desktop Testing*/
// the idea is that you have to hold the right mouse button to do rotations
UFUNCTION()
void StartDesktopRotation();
UFUNCTION()
void EndDesktopRotation();
protected:
void SetupInputActions();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input")
class UInputMappingContext* IMCRotation;
private:
bool bApplyDesktopRotation = false;
/**
* Fixes camera rotation in desktop mode.
*/
void SetCameraOffset() const;
void UpdateRightHandForDesktopInteraction() const;
};
......@@ -14,21 +14,12 @@
#include "NiagaraDataInterfaceArrayFunctionLibrary.h"
#include "Utility/VirtualRealityUtilities.h"
// Sets default values for this component's properties
UTeleportationComponent::UTeleportationComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
}
// Called when the game starts
void UTeleportationComponent::BeginPlay()
{
Super::BeginPlay();
VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
SetupInputActions();
TeleportTraceComponent = UNiagaraFunctionLibrary::SpawnSystemAtLocation
......@@ -53,20 +44,16 @@ void UTeleportationComponent::BeginPlay()
TeleportTraceComponent->SetVisibility(false);
TeleportVisualizer->SetActorHiddenInGame(true);
// ...
}
// Called every frame
void UTeleportationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UTeleportationComponent::SetupInputActions()
{
Super::SetupInputActions();
const AVirtualRealityPawn* VRPawn = Cast<AVirtualRealityPawn>(GetOwner());
// simple way of changing the handedness
if(bMoveWithRightHand)
{
......@@ -97,47 +84,13 @@ void UTeleportationComponent::SetupInputActions()
return;
}
// walking
// teleporting
EI->BindAction(Move, ETriggerEvent::Started, this, &UTeleportationComponent::OnStartTeleportTrace);
EI->BindAction(Move, ETriggerEvent::Triggered, this, &UTeleportationComponent::UpdateTeleportTrace);
EI->BindAction(Move, ETriggerEvent::Completed, this, &UTeleportationComponent::OnEndTeleportTrace);
EI->BindAction(Move, ETriggerEvent::Canceled, this, &UTeleportationComponent::OnEndTeleportTrace);
// turning
if(bSnapTurn && !UVirtualRealityUtilities::IsDesktopMode())
{
EI->BindAction(Turn, ETriggerEvent::Started, this, &UTeleportationComponent::OnBeginSnapTurn);
} else
{
EI->BindAction(Turn, ETriggerEvent::Triggered, this, &UTeleportationComponent::OnBeginTurn);
}
// bind functions for desktop rotations only on holding down right mouse
if (UVirtualRealityUtilities::IsDesktopMode())
{
APlayerController* PC = Cast<APlayerController>(VRPawn->GetController());
if (PC)
{
PC->bShowMouseCursor = true;
PC->bEnableClickEvents = true;
PC->bEnableMouseOverEvents = true;
} else
{
UE_LOG(LogTemp,Error,TEXT("PC Player Controller is invalid"));
}
EI->BindAction(DesktopRotation, ETriggerEvent::Started, this, &UTeleportationComponent::StartDesktopRotation);
EI->BindAction(DesktopRotation, ETriggerEvent::Completed, this, &UTeleportationComponent::EndDesktopRotation);
}
}
void UTeleportationComponent::StartDesktopRotation()
{
bApplyDesktopRotation = true;
}
void UTeleportationComponent::EndDesktopRotation()
{
bApplyDesktopRotation = false;
// turning is defined in MovementComponentBase
}
// On button press -> show teleport trace
......@@ -227,64 +180,4 @@ void UTeleportationComponent::OnEndTeleportTrace(const FInputActionValue& Value)
}
void UTeleportationComponent::OnBeginTurn(const FInputActionValue& Value)
{
if(UVirtualRealityUtilities::IsDesktopMode() && !bApplyDesktopRotation) return;
if (VRPawn->Controller != nullptr)
{
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X != 0.f)
{
VRPawn->AddControllerYawInput(TurnRateFactor * TurnValue.X);
if (UVirtualRealityUtilities::IsDesktopMode())
{
UpdateRightHandForDesktopInteraction();
}
}
if (TurnValue.Y != 0.f)
{
if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation)
{
VRPawn->AddControllerPitchInput(TurnRateFactor * -TurnValue.Y);
SetCameraOffset();
}
}
}
}
void UTeleportationComponent::OnBeginSnapTurn(const FInputActionValue& Value)
{
const FVector2D TurnValue = Value.Get<FVector2D>();
if (TurnValue.X > 0.f)
{
VRPawn->AddControllerYawInput(SnapTurnAngle);
} else if (TurnValue.X < 0.f)
{
VRPawn->AddControllerYawInput(-SnapTurnAngle);
}
}
void UTeleportationComponent::SetCameraOffset() const
{
// this also incorporates the BaseEyeHeight, if set as static offset,
// rotations are still around the center of the pawn (on the floor), so pitch rotations look weird
FVector Location;
FRotator Rotation;
VRPawn->GetActorEyesViewPoint(Location, Rotation);
VRPawn->CameraComponent->SetWorldLocationAndRotation(Location, Rotation);
}
void UTeleportationComponent::UpdateRightHandForDesktopInteraction()
{
APlayerController* PC = Cast<APlayerController>(VRPawn->GetController());
if (PC)
{
FVector MouseLocation, MouseDirection;
PC->DeprojectMousePositionToWorld(MouseLocation, MouseDirection);
FRotator HandOrientation = MouseDirection.ToOrientationRotator();
VRPawn->RightHand->SetWorldRotation(HandOrientation);
}
}
......@@ -103,6 +103,10 @@ void AVirtualRealityPawn::OnToggleNavigationMode(const FInputActionValue& Value)
break;
case EVRNavigationModes::NAV_WALK:
PawnMovement->NavigationMode = EVRNavigationModes::NAV_GHOST;
UE_LOG(Toolkit,Log,TEXT("Changed Nav mode to GHOST"));
break;
case EVRNavigationModes::NAV_GHOST:
PawnMovement->NavigationMode = EVRNavigationModes::NAV_FLY;
UE_LOG(Toolkit, Log, TEXT("Changed Nav mode to FLY"));
break;
......
......@@ -4,6 +4,7 @@
#include "CoreMinimal.h"
#include "Pawn/VirtualRealityPawn.h"
#include "Pawn/MovementComponentBase.h"
#include "Components/ActorComponent.h"
#include "ContinuousMovementComponent.generated.h"
......@@ -19,7 +20,7 @@ enum class EVRSteeringModes : uint8
*
*/
UCLASS(Blueprintable)
class RWTHVRTOOLKIT_API UContinuousMovementComponent : public UActorComponent
class RWTHVRTOOLKIT_API UContinuousMovementComponent : public UMovementComponentBase
{
GENERATED_BODY()
......@@ -33,17 +34,6 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
bool bMoveWithRightHand = true;
UPROPERTY(EditAnywhere,BlueprintReadWrite, Category = "VR Movement")
bool bAllowTurning = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta=(EditCondition="bAllowTurning"))
bool bSnapTurn = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta=(EditCondition="!bSnapTurn && bAllowTurning"))
float TurnRateFactor = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta=(EditCondition="bSnapTurn && bAllowTurning",ClampMin=0,ClampMax=360))
float SnapTurnAngle = 22.5;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input")
class UInputMappingContext* IMCMovementLeft;
......@@ -54,12 +44,6 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* Move;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* Turn;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* DesktopRotation;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* MoveUp;
......@@ -67,45 +51,20 @@ public:
UFUNCTION(BlueprintCallable)
void OnBeginMove(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginTurn(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginSnapTurn(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginUp(const FInputActionValue& Value);
/*Desktop Testing*/
// the idea is that you have to hold the right mouse button to do rotations
UFUNCTION()
void StartDesktopRotation();
UFUNCTION()
void EndDesktopRotation();
bool bApplyDesktopRotation = false;
private:
UPROPERTY()
UUniversalTrackedComponent* MovementHand;
UPROPERTY()
UUniversalTrackedComponent* RotationHand;
UPROPERTY()
class UInputMappingContext* IMCMovement;
void SetupInputActions();
UPROPERTY()
AVirtualRealityPawn* VRPawn;
UUniversalTrackedComponent* MovementHand;
/**
* Fixes camera rotation in desktop mode.
*/
void SetCameraOffset() const;
void UpdateRightHandForDesktopInteraction();
UPROPERTY()
UUniversalTrackedComponent* RotationHand;
virtual void SetupInputActions();
};
......@@ -7,46 +7,26 @@
#include "Pawn/VirtualRealityPawn.h"
#include "NiagaraComponent.h"
#include "Kismet/GameplayStaticsTypes.h"
#include "Pawn/MovementComponentBase.h"
#include "TeleportationComponent.generated.h"
UCLASS(Blueprintable)
class RWTHVRTOOLKIT_API UTeleportationComponent : public UActorComponent
class RWTHVRTOOLKIT_API UTeleportationComponent : public UMovementComponentBase
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UTeleportationComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
bool bMoveWithRightHand = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
bool bAllowTurning = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta=(EditCondition="bAllowTurning"))
bool bSnapTurn = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning",
meta=(EditCondition="!bSnapTurn && bAllowTurning"))
float TurnRateFactor = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning",
meta=(EditCondition="bSnapTurn && bAllowTurning", ClampMin=0, ClampMax=360))
float SnapTurnAngle = 22.5;
/**
* Whether the hit location of the teleport trace should be projected onto the navigation mesh
* TODO: does currently not work, so leave it at false
......@@ -71,12 +51,6 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* Move;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* Turn;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
class UInputAction* DesktopRotation;
/*Movement Input*/
UFUNCTION(BlueprintCallable)
void OnStartTeleportTrace(const FInputActionValue& Value);
......@@ -87,24 +61,6 @@ public:
UFUNCTION(BlueprintCallable)
void OnEndTeleportTrace(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginTurn(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnBeginSnapTurn(const FInputActionValue& Value);
/*Desktop Testing*/
// the idea is that you have to hold the right mouse button to do rotations
UFUNCTION()
void StartDesktopRotation();
UFUNCTION()
void EndDesktopRotation();
bool bApplyDesktopRotation = false;
// Trace Visualization
UPROPERTY(EditAnywhere)
TSubclassOf<AActor> BPTeleportVisualizer;
......@@ -125,16 +81,7 @@ private:
UPROPERTY()
class UInputMappingContext* IMCMovement;
void SetupInputActions();
UPROPERTY()
AVirtualRealityPawn* VRPawn;
/**
* Fixes camera rotation in desktop mode.
*/
void SetCameraOffset() const;
void UpdateRightHandForDesktopInteraction();
virtual void SetupInputActions();
bool bTeleportTraceActive;
float TeleportProjectileRadius = 3.6;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment