diff --git a/Content/BP_VirtualRealityPawn.uasset b/Content/BP_VirtualRealityPawn.uasset index de6a205060c6131ae6724b3246de1ef437f2b6ec..2870c55ca9d0135f07db10a523b0f6c111a92caa 100644 Binary files a/Content/BP_VirtualRealityPawn.uasset and b/Content/BP_VirtualRealityPawn.uasset differ diff --git a/Content/Components/Movement/IMC_MovementLeftHand.uasset b/Content/Components/Movement/IMC_MovementLeftHand.uasset index 6762960518fa317c48d0effb0e173a6f09f2e763..155f287eb0a79caf26c6539da0dcc303e06309b5 100644 Binary files a/Content/Components/Movement/IMC_MovementLeftHand.uasset and b/Content/Components/Movement/IMC_MovementLeftHand.uasset differ diff --git a/Content/Components/Movement/IMC_MovementRightHand.uasset b/Content/Components/Movement/IMC_MovementRightHand.uasset index c848335f083150cd0393bb64dac0495a9aaa949e..2af1ca1edd6584f443c7b266dc06c62f35e716aa 100644 Binary files a/Content/Components/Movement/IMC_MovementRightHand.uasset and b/Content/Components/Movement/IMC_MovementRightHand.uasset differ diff --git a/Content/Input/IMC_RWTH_Base.uasset b/Content/Input/IMC_RWTH_Base.uasset index 9f2e4864bdd16cd30a452191d9ac298cd579e460..90c92e351646615863813e7c77ebba0c3cedd8b5 100644 Binary files a/Content/Input/IMC_RWTH_Base.uasset and b/Content/Input/IMC_RWTH_Base.uasset differ diff --git a/Content/RWTHVRGameMode.uasset b/Content/RWTHVRGameMode.uasset index c3904e554dfa66dd200f0e61e318efac52b09a3a..72b55a3feed2c36b8d8892016be9e0dd513d6232 100644 Binary files a/Content/RWTHVRGameMode.uasset and b/Content/RWTHVRGameMode.uasset differ diff --git a/Content/TestMap.umap b/Content/TestMap.umap index 7e7113328a4bc24bfdcbdc7f61a83af3a8cc305f..eb51ef631942a0ef7e8ae3c71c0a0733fb8e1746 100644 Binary files a/Content/TestMap.umap and b/Content/TestMap.umap differ diff --git a/Source/RWTHVRToolkit/Private/Pawn/ContinuousMovementComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/ContinuousMovementComponent.cpp index c931c7c281a5050d4a11ea5e9e22621548fa5ac2..4f7db1bca286acdd190d0aba772385422c96fba0 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/ContinuousMovementComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/ContinuousMovementComponent.cpp @@ -3,166 +3,22 @@ #include "Pawn/ContinuousMovementComponent.h" -#include "DrawDebugHelpers.h" #include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" -#include "Camera/CameraComponent.h" -#include "Components/CapsuleComponent.h" #include "Engine/LocalPlayer.h" #include "GameFramework/PlayerController.h" #include "Pawn/VRPawnInputConfig.h" #include "Utility/VirtualRealityUtilities.h" -UContinuousMovementComponent::UContinuousMovementComponent(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) -{ - CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider")); - CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); - CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap); - CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block); - CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, 80.0f); - - VRPawn = Cast<AVirtualRealityPawn>(GetOwner()); -} - -void UContinuousMovementComponent::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){ - - SetCapsuleColliderToUserSize(); - - FVector PositionChange = GetPendingInputVector(); - - if (NavigationMode == EVRNavigationModes::NAV_WALK) - { - PositionChange.Z = 0.0f; - ConsumeInputVector(); - AddInputVector(PositionChange); - } - - if(NavigationMode == EVRNavigationModes::NAV_FLY || NavigationMode == EVRNavigationModes::NAV_WALK) - { - MoveByGravityOrStepUp(DeltaTime); - CheckForPhysWalkingCollision(); - - if(CheckForVirtualMovCollision(PositionChange, DeltaTime)) - { - ConsumeInputVector(); - } - } - - if(NavigationMode == EVRNavigationModes::NAV_NONE) - { - ConsumeInputVector(); - } - - Super::TickComponent(DeltaTime, TickType, ThisTickFunction); - - LastHeadPosition = HeadComponent->GetComponentLocation(); -} - void UContinuousMovementComponent::BeginPlay() { Super::BeginPlay(); - - SetUpdatedComponent(VRPawn->GetRootComponent()); - SetHeadComponent(VRPawn->CapsuleRotationFix); + VRPawn = Cast<AVirtualRealityPawn>(GetOwner()); SetupInputActions(); } -bool UContinuousMovementComponent::CheckForVirtualMovCollision(FVector PositionChange, float DeltaTime) -{ - FVector ProbePosition = PositionChange.GetSafeNormal() * GetMaxSpeed() * DeltaTime; - FHitResult FHitResultVR; - CapsuleColliderComponent->AddWorldOffset(ProbePosition, true, &FHitResultVR); - if (FVector::Distance(FHitResultVR.Location, CapsuleColliderComponent->GetComponentLocation()) < CapsuleColliderComponent->GetScaledCapsuleRadius()) - { - return true; - } - return false; -} - -void UContinuousMovementComponent::SetHeadComponent(USceneComponent* NewHeadComponent) -{ - HeadComponent = NewHeadComponent; - CapsuleColliderComponent->SetupAttachment(HeadComponent); - const float HalfHeight = 80.0f; //this is just an initial value to look good in editor - CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, HalfHeight); - CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f,HalfHeight)); -} - -void UContinuousMovementComponent::SetCapsuleColliderToUserSize() -{ - float CharachterSize = abs(UpdatedComponent->GetComponentLocation().Z - HeadComponent->GetComponentLocation().Z); - - if (CharachterSize > MaxStepHeight) - { - float ColliderHeight = CharachterSize - MaxStepHeight; - float ColliderHalfHeight = ColliderHeight / 2.0f; - if (ColliderHalfHeight <= CapsuleRadius) - {//Make the collider to a Sphere - CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight); - } - else - {//Make the collider to a Capsule - CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight); - } - - CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); - CapsuleColliderComponent->AddWorldOffset(FVector(0, 0, -ColliderHalfHeight)); - CapsuleColliderComponent->SetWorldRotation(FRotator(0, 0, 1)); - } - else - { - CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); - CapsuleColliderComponent->SetWorldRotation(FRotator(0, 0, 1)); - } -} - -void UContinuousMovementComponent::CheckForPhysWalkingCollision() -{ - FVector CurrentHeadPosition = HeadComponent->GetComponentLocation(); - FVector Direction = CurrentHeadPosition - LastHeadPosition; - FHitResult FHitResultPhys; - CapsuleColliderComponent->AddWorldOffset(Direction, true, &FHitResultPhys); - - if (FHitResultPhys.bBlockingHit) - { - UpdatedComponent->AddLocalOffset(FHitResultPhys.Normal*FHitResultPhys.PenetrationDepth); - } -} - -void UContinuousMovementComponent::MoveByGravityOrStepUp(float DeltaSeconds) -{ - FVector StartLineTraceUnderCollider = CapsuleColliderComponent->GetComponentLocation(); - StartLineTraceUnderCollider.Z -= CapsuleColliderComponent->GetScaledCapsuleHalfHeight(); - FHitResult HitDetailsMultiLineTrace = CreateMultiLineTrace(FVector(0, 0, -1), StartLineTraceUnderCollider, CapsuleColliderComponent->GetScaledCapsuleRadius() / 4.0f, false); - float DistanceDifference = abs(MaxStepHeight - HitDetailsMultiLineTrace.Distance); - //Going up (in Fly and Walk Mode) - if ((HitDetailsMultiLineTrace.bBlockingHit && HitDetailsMultiLineTrace.Distance < MaxStepHeight)) - { - ShiftVertically(DistanceDifference, UpSteppingAcceleration, DeltaSeconds, 1); - } - //Gravity (only in Walk Mode) - else if (NavigationMode==EVRNavigationModes::NAV_WALK && ((HitDetailsMultiLineTrace.bBlockingHit && HitDetailsMultiLineTrace.Distance > MaxStepHeight) || (HitDetailsMultiLineTrace.GetActor() == nullptr && HitDetailsMultiLineTrace.Distance != -1.0f))) - { - ShiftVertically(DistanceDifference, GravityAcceleration, DeltaSeconds, -1); - } -} - -void UContinuousMovementComponent::ShiftVertically(float DiffernceDistance, float VerticalAcceleration, float DeltaSeconds, int Direction) -{ - VerticalSpeed += VerticalAcceleration * DeltaSeconds; - if (VerticalSpeed*DeltaSeconds < DiffernceDistance) - { - UpdatedComponent->AddLocalOffset(FVector(0.f, 0.f, Direction * VerticalSpeed * DeltaSeconds)); - } - else - { - UpdatedComponent->AddLocalOffset(FVector(0.f, 0.f, Direction * DiffernceDistance)); - VerticalSpeed = 0; - } -} - void UContinuousMovementComponent::SetupInputActions() { // simple way of changing the handedness @@ -216,69 +72,18 @@ void UContinuousMovementComponent::SetupInputActions() APlayerController* PC = Cast<APlayerController>(VRPawn->GetController()); if (PC) { + UE_LOG(LogTemp,Error,TEXT("PC PLAYER CONtroller is valid")); PC->bShowMouseCursor = true; PC->bEnableClickEvents = true; PC->bEnableMouseOverEvents = true; } EI->BindAction(InputActions->DesktopRotation, ETriggerEvent::Started, this, &UContinuousMovementComponent::StartDesktopRotation); EI->BindAction(InputActions->DesktopRotation, ETriggerEvent::Completed, this, &UContinuousMovementComponent::EndDesktopRotation); - } -} - - -FHitResult UContinuousMovementComponent::CreateLineTrace(FVector Direction, const FVector Start, bool Visibility) -{ - //Re-initialize hit info - FHitResult HitDetails = FHitResult(ForceInit); - - FVector End = ((Direction * 1000.f) + Start); - // additional trace parameters - FCollisionQueryParams TraceParams(FName(TEXT("InteractTrace")), true, NULL); - TraceParams.bTraceComplex = true; //to use complex collision on whatever we interact with to provide better precision. - TraceParams.bReturnPhysicalMaterial = true; //to provide details about the physical material, if one exists on the thing we hit, to come back in our hit result. - - if (Visibility) - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1, 0, 1); - - if (GetWorld()->LineTraceSingleByChannel(HitDetails, Start, End, ECC_Visibility, TraceParams)) - { - if (HitDetails.bBlockingHit) - { - } + EI->BindAction(InputActions->MoveUp, ETriggerEvent::Triggered,this,&UContinuousMovementComponent::OnBeginUp); } - return HitDetails; } -FHitResult UContinuousMovementComponent::CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility) -{ - TArray<FVector> StartVectors; - TArray<FHitResult> OutHits; - FHitResult HitDetailsMultiLineTrace; - HitDetailsMultiLineTrace.Distance = -1.0f;//(Distance=-1) not existing, but to know if this Variable not Initialized(when all Traces not compatible) - - StartVectors.Add(Start); //LineTraceCenter - StartVectors.Add(Start + FVector(0, -Radius, 0)); //LineTraceLeft - StartVectors.Add(Start + FVector(0, +Radius, 0)); //LineTraceRight - StartVectors.Add(Start + FVector(+Radius, 0, 0)); //LineTraceFront - StartVectors.Add(Start + FVector(-Radius, 0, 0)); //LineTraceBehind - - bool IsBlockingHitAndSameActor = true; - bool IsAllNothingHiting = true; - // loop through TArray - for (FVector& Vector : StartVectors) - { - FHitResult OutHit = CreateLineTrace(Direction, Vector, Visibility); - OutHits.Add(OutHit); - IsBlockingHitAndSameActor &= (OutHit.GetActor() == OutHits[0].GetActor()); //If all Hiting the same Object, then you are (going up/down) or (walking) - IsAllNothingHiting &= (OutHit.GetActor() == nullptr); //If all Hiting nothing, then you are falling - } - - if (IsBlockingHitAndSameActor || IsAllNothingHiting) - HitDetailsMultiLineTrace = OutHits[0]; - - return HitDetailsMultiLineTrace; -} void UContinuousMovementComponent::StartDesktopRotation() { @@ -292,13 +97,15 @@ void UContinuousMovementComponent::EndDesktopRotation() void UContinuousMovementComponent::OnBeginMove(const FInputActionValue& Value) { - const FVector ForwardDir = UVirtualRealityUtilities::IsDesktopMode() ? VRPawn->Head->GetForwardVector() : MovementHand->GetForwardVector(); - const FVector RightDir = UVirtualRealityUtilities::IsDesktopMode() ? VRPawn->Head->GetRightVector() : MovementHand->GetRightVector(); + + const bool bGazeDirected = UVirtualRealityUtilities::IsDesktopMode() || SteeringMode == EVRSteeringModes::STEER_GAZE_DIRECTED; + + const FVector ForwardDir = bGazeDirected ? VRPawn->Head->GetForwardVector() : MovementHand->GetForwardVector(); + const FVector RightDir = bGazeDirected ? VRPawn->Head->GetRightVector() : MovementHand->GetRightVector(); if (VRPawn->Controller != nullptr) { const FVector2D MoveValue = Value.Get<FVector2D>(); - const FRotator MovementRotation(0, VRPawn->Controller->GetControlRotation().Yaw, 0); // Forward/Backward direction if (MoveValue.X != 0.f) @@ -363,7 +170,7 @@ void UContinuousMovementComponent::SetCameraOffset() const void UContinuousMovementComponent::UpdateRightHandForDesktopInteraction() { - APlayerController* PC = Cast<APlayerController>(GetController()); + APlayerController* PC = Cast<APlayerController>(VRPawn->GetController()); if (PC) { FVector MouseLocation, MouseDirection; @@ -373,21 +180,11 @@ void UContinuousMovementComponent::UpdateRightHandForDesktopInteraction() } } -/*void UContinuousMovementComponent::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) +void UContinuousMovementComponent::OnBeginUp(const FInputActionValue& Value) { - Super::PostEditChangeProperty(PropertyChangedEvent); + const float MoveValue = Value.Get<FVector2D>().X; + UE_LOG(LogTemp,Warning,TEXT("MoveUp: %f"),MoveValue); + //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position + VRPawn->AddMovementInput(VRPawn->Head->GetUpVector(), MoveValue); - FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None; - - if (PropertyName == GET_MEMBER_NAME_CHECKED(AVirtualRealityPawn, bMoveWithRightHand) || - PropertyName == GET_MEMBER_NAME_CHECKED(AVirtualRealityPawn, bSnapTurn)) - { - // if we want to change input bindings, we need to setup the player input again to load a different mapping context, - // or assign a different function to an input action. - // This is automatically done by restarting the pawn(calling SetupPlayerInputComponent() directly results in crashes) - // only do this in the editor - #if WITH_EDITOR - VRPawn->Restart(); -#endif - } -}*/ \ No newline at end of file +} \ No newline at end of file diff --git a/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b32da4736f6a6e3ea7b9423fac8540926985126 --- /dev/null +++ b/Source/RWTHVRToolkit/Private/Pawn/VRPawnMovement.cpp @@ -0,0 +1,193 @@ + +#include "Pawn/VRPawnMovement.h" +#include "DrawDebugHelpers.h" + +UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) +{ + CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider")); + CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); + CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap); + CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block); + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, 80.0f); +} + +void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){ + + SetCapsuleColliderToUserSize(); + + FVector PositionChange = GetPendingInputVector(); + + if (NavigationMode == EVRNavigationModes::NAV_WALK) + { + PositionChange.Z = 0.0f; + ConsumeInputVector(); + AddInputVector(PositionChange); + } + + if(NavigationMode == EVRNavigationModes::NAV_FLY || NavigationMode == EVRNavigationModes::NAV_WALK) + { + MoveByGravityOrStepUp(DeltaTime); + CheckForPhysWalkingCollision(); + + if(CheckForVirtualMovCollision(PositionChange, DeltaTime)) + { + ConsumeInputVector(); + } + } + + if(NavigationMode == EVRNavigationModes::NAV_NONE) + { + ConsumeInputVector(); + } + + Super::TickComponent(DeltaTime, TickType, ThisTickFunction); + + LastHeadPosition = HeadComponent->GetComponentLocation(); +} + +bool UVRPawnMovement::CheckForVirtualMovCollision(FVector PositionChange, float DeltaTime) +{ + FVector ProbePosition = PositionChange.GetSafeNormal() * GetMaxSpeed() * DeltaTime; + FHitResult FHitResultVR; + CapsuleColliderComponent->AddWorldOffset(ProbePosition, true, &FHitResultVR); + if (FVector::Distance(FHitResultVR.Location, CapsuleColliderComponent->GetComponentLocation()) < CapsuleColliderComponent->GetScaledCapsuleRadius()) + { + return true; + } + return false; +} + +void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent) +{ + HeadComponent = NewHeadComponent; + CapsuleColliderComponent->SetupAttachment(HeadComponent); + const float HalfHeight = 80.0f; //this is just an initial value to look good in editor + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, HalfHeight); + CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f,HalfHeight)); +} + +void UVRPawnMovement::SetCapsuleColliderToUserSize() +{ + float CharachterSize = abs(UpdatedComponent->GetComponentLocation().Z - HeadComponent->GetComponentLocation().Z); + + if (CharachterSize > MaxStepHeight) + { + float ColliderHeight = CharachterSize - MaxStepHeight; + float ColliderHalfHeight = ColliderHeight / 2.0f; + if (ColliderHalfHeight <= CapsuleRadius) + {//Make the collider to a Sphere + CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight); + } + else + {//Make the collider to a Capsule + CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight); + } + + CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); + CapsuleColliderComponent->AddWorldOffset(FVector(0, 0, -ColliderHalfHeight)); + CapsuleColliderComponent->SetWorldRotation(FRotator(0, 0, 1)); + } + else + { + CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation()); + CapsuleColliderComponent->SetWorldRotation(FRotator(0, 0, 1)); + } +} + +void UVRPawnMovement::CheckForPhysWalkingCollision() +{ + FVector CurrentHeadPosition = HeadComponent->GetComponentLocation(); + FVector Direction = CurrentHeadPosition - LastHeadPosition; + FHitResult FHitResultPhys; + CapsuleColliderComponent->AddWorldOffset(Direction, true, &FHitResultPhys); + + if (FHitResultPhys.bBlockingHit) + { + UpdatedComponent->AddLocalOffset(FHitResultPhys.Normal*FHitResultPhys.PenetrationDepth); + } +} + +void UVRPawnMovement::MoveByGravityOrStepUp(float DeltaSeconds) +{ + FVector StartLineTraceUnderCollider = CapsuleColliderComponent->GetComponentLocation(); + StartLineTraceUnderCollider.Z -= CapsuleColliderComponent->GetScaledCapsuleHalfHeight(); + FHitResult HitDetailsMultiLineTrace = CreateMultiLineTrace(FVector(0, 0, -1), StartLineTraceUnderCollider, CapsuleColliderComponent->GetScaledCapsuleRadius() / 4.0f, false); + float DistanceDifference = abs(MaxStepHeight - HitDetailsMultiLineTrace.Distance); + //Going up (in Fly and Walk Mode) + if ((HitDetailsMultiLineTrace.bBlockingHit && HitDetailsMultiLineTrace.Distance < MaxStepHeight)) + { + ShiftVertically(DistanceDifference, UpSteppingAcceleration, DeltaSeconds, 1); + } + //Gravity (only in Walk Mode) + else if (NavigationMode==EVRNavigationModes::NAV_WALK && ((HitDetailsMultiLineTrace.bBlockingHit && HitDetailsMultiLineTrace.Distance > MaxStepHeight) || (HitDetailsMultiLineTrace.GetActor() == nullptr && HitDetailsMultiLineTrace.Distance != -1.0f))) + { + ShiftVertically(DistanceDifference, GravityAcceleration, DeltaSeconds, -1); + } +} + +void UVRPawnMovement::ShiftVertically(float DiffernceDistance, float VerticalAcceleration, float DeltaSeconds, int Direction) +{ + VerticalSpeed += VerticalAcceleration * DeltaSeconds; + if (VerticalSpeed*DeltaSeconds < DiffernceDistance) + { + UpdatedComponent->AddLocalOffset(FVector(0.f, 0.f, Direction * VerticalSpeed * DeltaSeconds)); + } + else + { + UpdatedComponent->AddLocalOffset(FVector(0.f, 0.f, Direction * DiffernceDistance)); + VerticalSpeed = 0; + } +} + +FHitResult UVRPawnMovement::CreateLineTrace(FVector Direction, const FVector Start, bool Visibility) +{ + //Re-initialize hit info + FHitResult HitDetails = FHitResult(ForceInit); + + FVector End = ((Direction * 1000.f) + Start); + // additional trace parameters + FCollisionQueryParams TraceParams(FName(TEXT("InteractTrace")), true, NULL); + TraceParams.bTraceComplex = true; //to use complex collision on whatever we interact with to provide better precision. + TraceParams.bReturnPhysicalMaterial = true; //to provide details about the physical material, if one exists on the thing we hit, to come back in our hit result. + + if (Visibility) + DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1, 0, 1); + + if (GetWorld()->LineTraceSingleByChannel(HitDetails, Start, End, ECC_Visibility, TraceParams)) + { + if (HitDetails.bBlockingHit) + { + } + } + return HitDetails; +} + +FHitResult UVRPawnMovement::CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility) +{ + TArray<FVector> StartVectors; + TArray<FHitResult> OutHits; + FHitResult HitDetailsMultiLineTrace; + HitDetailsMultiLineTrace.Distance = -1.0f;//(Distance=-1) not existing, but to know if this Variable not Initialized(when all Traces not compatible) + + StartVectors.Add(Start); //LineTraceCenter + StartVectors.Add(Start + FVector(0, -Radius, 0)); //LineTraceLeft + StartVectors.Add(Start + FVector(0, +Radius, 0)); //LineTraceRight + StartVectors.Add(Start + FVector(+Radius, 0, 0)); //LineTraceFront + StartVectors.Add(Start + FVector(-Radius, 0, 0)); //LineTraceBehind + + bool IsBlockingHitAndSameActor = true; + bool IsAllNothingHiting = true; + // loop through TArray + for (FVector& Vector : StartVectors) + { + FHitResult OutHit = CreateLineTrace(Direction, Vector, Visibility); + OutHits.Add(OutHit); + IsBlockingHitAndSameActor &= (OutHit.GetActor() == OutHits[0].GetActor()); //If all Hiting the same Object, then you are (going up/down) or (walking) + IsAllNothingHiting &= (OutHit.GetActor() == nullptr); //If all Hiting nothing, then you are falling + } + + if (IsBlockingHitAndSameActor || IsAllNothingHiting) + HitDetailsMultiLineTrace = OutHits[0]; + + return HitDetailsMultiLineTrace; +} \ No newline at end of file diff --git a/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp index 3676a7900a0d529223eeb5416d2a9aea6031994c..a0afeac4e54b592edc0750b6c7ba6f26353b30d0 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp @@ -11,6 +11,7 @@ #include "EnhancedInputSubsystems.h" #include "Camera/CameraComponent.h" #include "Pawn/VRPawnInputConfig.h" +#include "Pawn/VRPawnMovement.h" AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -34,10 +35,10 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial CapsuleRotationFix = CreateDefaultSubobject<USceneComponent>(TEXT("CapsuleRotationFix")); CapsuleRotationFix->SetUsingAbsoluteRotation(true); CapsuleRotationFix->SetupAttachment(Head); - - /*PawnMovement = CreateDefaultSubobject<UVRPawnMovement>(TEXT("Pawn Movement")); + + PawnMovement = CreateDefaultSubobject<UVRPawnMovement>(TEXT("Pawn Movement")); PawnMovement->SetUpdatedComponent(RootComponent); - PawnMovement->SetHeadComponent(CapsuleRotationFix);*/ + PawnMovement->SetHeadComponent(CapsuleRotationFix); RightHand = CreateDefaultSubobject<UUniversalTrackedComponent>(TEXT("Right Hand")); RightHand->ProxyType = ETrackedComponentType::TCT_RIGHT_HAND; @@ -59,20 +60,6 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) { - - // simple way of changing the handedness - /*if(bMoveWithRightHand) - { - MovementHand = RightHand; - RotationHand = LeftHand; - IMCMovement = IMCMovementRight; - } else - { - MovementHand = LeftHand; - RotationHand = RightHand; - IMCMovement = IMCMovementLeft; - }*/ - const APlayerController* PlayerController = Cast<APlayerController>(GetController()); UEnhancedInputLocalPlayerSubsystem* InputSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()); if(!InputSubsystem) @@ -83,7 +70,6 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput InputSubsystem->ClearAllMappings(); // add Input Mapping context - //InputSubsystem->AddMappingContext(IMCMovement,0); InputSubsystem->AddMappingContext(IMCBase,0); UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(PlayerInputComponent); @@ -95,101 +81,7 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput // grabbing EI->BindAction(InputActions->Grab, ETriggerEvent::Started, this, &AVirtualRealityPawn::OnBeginGrab); EI->BindAction(InputActions->Grab, ETriggerEvent::Completed, this, &AVirtualRealityPawn::OnEndGrab); - - /*// walking - EI->BindAction(InputActions->Move, ETriggerEvent::Triggered, this, &AVirtualRealityPawn::OnBeginMove);*/ - - /* - // turning - if(bSnapTurn && !UVirtualRealityUtilities::IsDesktopMode()) - { - EI->BindAction(InputActions->Turn, ETriggerEvent::Started, this, &AVirtualRealityPawn::OnBeginSnapTurn); - } else - { - EI->BindAction(InputActions->Turn, ETriggerEvent::Triggered, this, &AVirtualRealityPawn::OnBeginTurn); - } - */ - - // bind functions for desktop rotations only on holding down right mouse - if (UVirtualRealityUtilities::IsDesktopMode()) - { - APlayerController* PC = Cast<APlayerController>(GetController()); - if (PC) - { - PC->bShowMouseCursor = true; - PC->bEnableClickEvents = true; - PC->bEnableMouseOverEvents = true; - } - /*EI->BindAction(InputActions->DesktopRotation, ETriggerEvent::Started, this, &AVirtualRealityPawn::StartDesktopRotation); - EI->BindAction(InputActions->DesktopRotation, ETriggerEvent::Completed, this, &AVirtualRealityPawn::EndDesktopRotation);*/ - } -} - -/*void AVirtualRealityPawn::StartDesktopRotation() -{ - bApplyDesktopRotation = true; -} - -void AVirtualRealityPawn::EndDesktopRotation() -{ - bApplyDesktopRotation = false; -}*/ - -/*void AVirtualRealityPawn::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; - GetActorEyesViewPoint(Location, Rotation); - CameraComponent->SetWorldLocationAndRotation(Location, Rotation); -}*/ - -/*void AVirtualRealityPawn::UpdateRightHandForDesktopInteraction() -{ - APlayerController* PC = Cast<APlayerController>(GetController()); - if (PC) - { - FVector MouseLocation, MouseDirection; - PC->DeprojectMousePositionToWorld(MouseLocation, MouseDirection); - FRotator HandOrientation = MouseDirection.ToOrientationRotator(); - RightHand->SetWorldRotation(HandOrientation); - } -}*/ - -/*void AVirtualRealityPawn::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) -{ - Super::PostEditChangeProperty(PropertyChangedEvent); - FName PropertyName = (PropertyChangedEvent.Property != NULL) ? PropertyChangedEvent.Property->GetFName() : NAME_None; - - if (PropertyName == GET_MEMBER_NAME_CHECKED(AVirtualRealityPawn, bMoveWithRightHand) || - PropertyName == GET_MEMBER_NAME_CHECKED(AVirtualRealityPawn, bSnapTurn)) - { - // if we want to change input bindings, we need to setup the player input again to load a different mapping context, - // or assign a different function to an input action. - // This is automatically done by restarting the pawn(calling SetupPlayerInputComponent() directly results in crashes) - // only do this in the editor - #if WITH_EDITOR - Restart(); - #endif - } -}*/ - - -void AVirtualRealityPawn::OnUp(const FInputActionValue& Value) -{ - const float MoveValue = Value.Get<FVector2D>().X; - UE_LOG(LogTemp,Warning,TEXT("MoveUp: %f"),MoveValue); - //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position - if (RightHand && !UVirtualRealityUtilities::IsDesktopMode()) - { - AddMovementInput(RightHand->GetUpVector(), MoveValue); - } - else if (Head) - { - AddMovementInput(Head->GetUpVector(), MoveValue); - } } // legacy grabbing @@ -216,65 +108,4 @@ void AVirtualRealityPawn::OnEndGrab(const FInputActionValue& Value) UE_LOG(LogTemp,Warning,TEXT("EndGrab")); } -/*void AVirtualRealityPawn::OnBeginMove(const FInputActionValue& Value) -{ - const FVector ForwardDir = UVirtualRealityUtilities::IsDesktopMode() ? Head->GetForwardVector() : MovementHand->GetForwardVector(); - const FVector RightDir = UVirtualRealityUtilities::IsDesktopMode() ? Head->GetRightVector() : MovementHand->GetRightVector(); - - if (Controller != nullptr) - { - const FVector2D MoveValue = Value.Get<FVector2D>(); - const FRotator MovementRotation(0, Controller->GetControlRotation().Yaw, 0); - - // Forward/Backward direction - if (MoveValue.X != 0.f) - { - AddMovementInput(ForwardDir, MoveValue.X); - } - - // Right/Left direction - if (MoveValue.Y != 0.f) - { - AddMovementInput(RightDir, MoveValue.Y); - } - } -}*/ - -/*void AVirtualRealityPawn::OnBeginTurn(const FInputActionValue& Value) -{ - if(UVirtualRealityUtilities::IsDesktopMode() && !bApplyDesktopRotation) return; - if (Controller != nullptr) - { - const FVector2D TurnValue = Value.Get<FVector2D>(); - - if (TurnValue.X != 0.f) - { - AddControllerYawInput(TurnRateFactor * TurnValue.X); - if (UVirtualRealityUtilities::IsDesktopMode()) - { - UpdateRightHandForDesktopInteraction(); - } - } - - if (TurnValue.Y != 0.f) - { - if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation) - { - AddControllerPitchInput(TurnRateFactor * TurnValue.Y); - SetCameraOffset(); - } - } - } -} - -void AVirtualRealityPawn::OnBeginSnapTurn(const FInputActionValue& Value) -{ - const FVector2D TurnValue = Value.Get<FVector2D>(); - - if (TurnValue.X != 0.f) - { - AddControllerYawInput(SnapTurnAngle); - } -}*/ - diff --git a/Source/RWTHVRToolkit/Public/Pawn/ContinuousMovementComponent.h b/Source/RWTHVRToolkit/Public/Pawn/ContinuousMovementComponent.h index fb335133431678cc9a7e4bd312bc8cc8a23ea959..0b068288c1d6429c75b879979850c536bcae844d 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/ContinuousMovementComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/ContinuousMovementComponent.h @@ -3,68 +3,54 @@ #pragma once #include "CoreMinimal.h" -#include "GameFramework/FloatingPawnMovement.h" -#include "Components/CapsuleComponent.h" #include "Pawn/VirtualRealityPawn.h" - +#include "Components/ActorComponent.h" #include "ContinuousMovementComponent.generated.h" -/* - * This Movement component is needed since in VR not only the pawn itself (UpdatedComponent) is moved but also the - * user herself can walk and thereby move the CameraComponent, which can also lead to collisions or e.g. going up steps - * - * The four modes are: - * None: No controller movement is applied and no corrections regarding steps or collisions with walls are done - * Ghost: The same as above but now the Inputs can be used for unconstrained flying (also through objects) - * Fly: The user can fly but not through walls etc. When the user walks against a wall the scene is moved with her to avoid walking through - * The user can also walk up stairs with a maximum step height of MaxStepHeight - * Walk: Additionally to Fly now gravity keeps the user on the floor - */ - UENUM(BlueprintType) -enum class EVRNavigationModes : uint8 +enum class EVRSteeringModes : uint8 { - NAV_NONE UMETA(DisplayName = "None (no controller movement)"), - NAV_GHOST UMETA(DisplayName = "Ghost (flying, also through walls)"), - NAV_FLY UMETA(DisplayName = "Fly (prohibiting collisions)"), - NAV_WALK UMETA(DisplayName = "Walk (gravity and prohibiting collisions)") + STEER_GAZE_DIRECTED UMETA(DisplayName = "Gaze Directed (Movement input is applied in head component direction)"), + STEER_HAND_DIRECTED UMETA(DisplayName = "Hand Direced (Movement input is applied in controller direction)") }; - /** * */ UCLASS(Blueprintable) -class RWTHVRTOOLKIT_API UContinuousMovementComponent : public UFloatingPawnMovement +class RWTHVRTOOLKIT_API UContinuousMovementComponent : public UActorComponent { GENERATED_BODY() public: - UContinuousMovementComponent(const FObjectInitializer& ObjectInitializer); - - virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; - virtual void BeginPlay() override; - void SetHeadComponent(USceneComponent* NewHeadComponent); - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - EVRNavigationModes NavigationMode = EVRNavigationModes::NAV_WALK; - + EVRSteeringModes SteeringMode = EVRSteeringModes::STEER_HAND_DIRECTED; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - float MaxStepHeight = 40.0f; + bool bMoveWithRightHand = false; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - float GravityAcceleration = 981.0f; + bool bSnapTurn = false; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - float UpSteppingAcceleration = 500.0f; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta=(EditCondition="!bSnapTurn")) + float TurnRateFactor = 1.0f; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - float CapsuleRadius = 40.0f; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta=(EditCondition="bSnapTurn",ClampMin=0,ClampMax=360)) + float SnapTurnAngle = 22.5; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") + class UInputMappingContext* IMCMovementRight; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") + class UInputMappingContext* IMCMovementLeft; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") + class UVRPawnInputConfig* InputActions; + /*Movement Input*/ @@ -77,14 +63,8 @@ public: UFUNCTION(BlueprintCallable) void OnBeginSnapTurn(const FInputActionValue& Value); - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") - class UInputMappingContext* IMCMovementRight; - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") - class UInputMappingContext* IMCMovementLeft; - - UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") - class UVRPawnInputConfig* InputActions; + UFUNCTION(BlueprintCallable) + void OnBeginUp(const FInputActionValue& Value); /*Desktop Testing*/ // the idea is that you have to hold the right mouse button to do rotations @@ -95,36 +75,10 @@ public: void EndDesktopRotation(); bool bApplyDesktopRotation = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - bool bMoveWithRightHand = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") - bool bSnapTurn = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta=(EditCondition="!bSnapTurn")) - float TurnRateFactor = 1.0f; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement", meta=(EditCondition="bSnapTurn",ClampMin=0,ClampMax=360)) - float SnapTurnAngle = 22.5; private: - FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility); - FHitResult CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility); - void SetCapsuleColliderToUserSize(); - void CheckForPhysWalkingCollision(); - bool CheckForVirtualMovCollision(FVector PositionChange, float DeltaTime); - void MoveByGravityOrStepUp(float DeltaSeconds); - void ShiftVertically(float DiffernceDistance, float VerticalAcceleration, float DeltaSeconds, int Direction); - //(direction = Down = -1), (direction = Up = 1) - - UPROPERTY(VisibleAnywhere) UCapsuleComponent* CapsuleColliderComponent = nullptr; - UPROPERTY() USceneComponent* HeadComponent = nullptr; - - float VerticalSpeed = 0.0f; - FVector LastHeadPosition; - - + + UPROPERTY() UUniversalTrackedComponent* MovementHand; @@ -136,10 +90,9 @@ private: void SetupInputActions(); + UPROPERTY() AVirtualRealityPawn* VRPawn; - /*virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;*/ - /** * Fixes camera rotation in desktop mode. */ diff --git a/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h b/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h new file mode 100644 index 0000000000000000000000000000000000000000..298799e58c5a0e3e5b9d03649ae3b71b94d1c87c --- /dev/null +++ b/Source/RWTHVRToolkit/Public/Pawn/VRPawnMovement.h @@ -0,0 +1,73 @@ +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/FloatingPawnMovement.h" +#include "Components/CapsuleComponent.h" +#include "Camera/CameraComponent.h" + +#include "VRPawnMovement.generated.h" + +/* + * This Movement component is needed since in VR not only the pawn itself (UpdatedComponent) is moved but also the + * user herself can walk and thereby move the CameraComponent, which can also lead to collisions or e.g. going up steps + * + * The four modes are: + * None: No controller movement is applied and no corrections regarding steps or collisions with walls are done + * Ghost: The same as above but now the Inputs can be used for unconstrained flying (also through objects) + * Fly: The user can fly but not through walls etc. When the user walks against a wall the scene is moved with her to avoid walking through + * The user can also walk up stairs with a maximum step height of MaxStepHeight + * Walk: Additionally to Fly now gravity keeps the user on the floor + */ + +UENUM(BlueprintType) +enum class EVRNavigationModes : uint8 +{ + NAV_NONE UMETA(DisplayName = "None (no controller movement)"), + NAV_GHOST UMETA(DisplayName = "Ghost (flying, also through walls)"), + NAV_FLY UMETA(DisplayName = "Fly (prohibiting collisions)"), + NAV_WALK UMETA(DisplayName = "Walk (gravity and prohibiting collisions)") +}; + +UCLASS() +class RWTHVRTOOLKIT_API UVRPawnMovement : public UFloatingPawnMovement +{ + GENERATED_UCLASS_BODY() + +public: + + virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, + FActorComponentTickFunction* ThisTickFunction) override; + + void SetHeadComponent(USceneComponent* NewHeadComponent); + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + EVRNavigationModes NavigationMode = EVRNavigationModes::NAV_WALK; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + float MaxStepHeight = 40.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + float GravityAcceleration = 981.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + float UpSteppingAcceleration = 500.0f; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") + float CapsuleRadius = 40.0f; + +private: + FHitResult CreateLineTrace(FVector Direction, const FVector Start, bool Visibility); + FHitResult CreateMultiLineTrace(FVector Direction, const FVector Start, float Radius, bool Visibility); + void SetCapsuleColliderToUserSize(); + void CheckForPhysWalkingCollision(); + bool CheckForVirtualMovCollision(FVector PositionChange, float DeltaTime); + void MoveByGravityOrStepUp(float DeltaSeconds); + void ShiftVertically(float DiffernceDistance, float VerticalAcceleration, float DeltaSeconds, int Direction); + //(direction = Down = -1), (direction = Up = 1) + + UPROPERTY(VisibleAnywhere) UCapsuleComponent* CapsuleColliderComponent = nullptr; + UPROPERTY() USceneComponent* HeadComponent = nullptr; + + float VerticalSpeed = 0.0f; + FVector LastHeadPosition; +}; diff --git a/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h b/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h index 79f7af9b8729e98943aef606f2001291956ef0df..ecca5440853ff0e8e9ad19b6990bc4c5c937dc5c 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h +++ b/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h @@ -5,6 +5,7 @@ #include "BasicVRInteractionComponent.h" #include "CoreMinimal.h" #include "UniversalTrackedComponent.h" +#include "Pawn/VRPawnMovement.h" #include "VirtualRealityPawn.generated.h" class UCameraComponent; @@ -32,22 +33,7 @@ public: /* Interaction */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Interaction") UBasicVRInteractionComponent* BasicVRInteraction; - - /* Movement */ - /*UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Movement") - UVRPawnMovement* PawnMovement;*/ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement") - bool bMoveWithRightHand = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement") - bool bSnapTurn = false; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement", meta=(EditCondition="!bSnapTurn")) - float TurnRateFactor = 1.0f; - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement", meta=(EditCondition="bSnapTurn",ClampMin=0,ClampMax=360)) - float SnapTurnAngle = 22.5; /** Workaround dummy component to prevent the Capsule from rotating in the editor, if LiveLink tracking is being used. * This happens due to the rotation of the Capsule being set only while in Play Mode (instead of using e.g. absolute rotation). @@ -58,7 +44,9 @@ public: */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement") USceneComponent* CapsuleRotationFix; - + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Movement") + UVRPawnMovement* PawnMovement; /* CameraComponent */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pawn|Camera") @@ -68,10 +56,6 @@ public: protected: virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override; - /* Movement */ - UFUNCTION(BlueprintCallable, Category = "Pawn|Movement") - void OnUp(const FInputActionValue& Value); - /* Interaction */ UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction") void OnBeginFire(const FInputActionValue& Value); @@ -84,17 +68,6 @@ protected: UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction") void OnEndGrab(const FInputActionValue& Value); - - /* - UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction") - void OnBeginMove(const FInputActionValue& Value); - - UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction") - void OnBeginTurn(const FInputActionValue& Value); - - UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction") - void OnBeginSnapTurn(const FInputActionValue& Value); - */ /* Input */ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pawn|Input") @@ -102,33 +75,5 @@ protected: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pawn|Input") class UVRPawnInputConfig* InputActions; - - /*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;*/ - - /** - * Fixes camera rotation in desktop mode. - */ - /*void SetCameraOffset() const; - void UpdateRightHandForDesktopInteraction();*/ - -private: - /*UPROPERTY() - UUniversalTrackedComponent* MovementHand; - - UPROPERTY() - UUniversalTrackedComponent* RotationHand; - - UPROPERTY() - class UInputMappingContext* IMCMovement;*/ - - /*virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;*/ };