Skip to content
Snippets Groups Projects
Commit 2b82ad57 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Merge branch 'refactor/remove_legacy' into 'dev/5.3'

refactor(pawn, interaction): removes legacy fire & toggle mode input actions

See merge request !52
parents 45215161 9ec1269b
Branches
No related tags found
No related merge requests found
Pipeline #329872 failed
Showing
with 217 additions and 319 deletions
No preview for this file type
File added
File added
File added
File deleted
File deleted
File deleted
// Fill out your copyright notice in the Description page of Project Settings.
#include "Interaction/Interactors/VRWidgetInteractionComponent.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "Interaction/Interactors/GrabComponent.h"
#include "Logging/StructuredLog.h"
#include "Misc/Optional.h"
#include "Utility/VirtualRealityUtilities.h"
UVRWidgetInteractionComponent::UVRWidgetInteractionComponent()
{
PrimaryComponentTick.bCanEverTick = true;
}
void UVRWidgetInteractionComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent)
{
IInputExtensionInterface::SetupPlayerInput(PlayerInputComponent);
const APawn* Pawn = Cast<APawn>(GetOwner());
// Check if our owner is a Pawn. Currently we call this function from our Pawn, so this is kind of a given.
// In the future, we might want to support other actors as well.
if (!Pawn)
{
UE_LOGFMT(Toolkit, Warning,
"UVRWidgetInteractionComponent::SetupPlayerInput requires a Pawn as Owner, which is not the case. Not setting up any input actions.")
;
return;
}
// We can be owned by a pawn, but not be the locally controlled pawn in a MP setting. In that case, just return and
// don't set up any inputs.
auto* InputSubsystem = GetEnhancedInputLocalPlayerSubsystem(Pawn);
if (!InputSubsystem)
return;
// Because we cannot use the regular debug ray (only works in editor), we set up our own (mesh) ray.
SetupInteractionRay();
// add Input Mapping context
InputSubsystem->AddMappingContext(IMCWidgetInteraction, 0);
UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(Pawn->InputComponent);
if (!EI)
{
UE_LOGFMT(Toolkit, Warning,
"UVRWidgetInteractionComponent::SetupPlayerInput: Cannot cast Pawn's InputComponent to UEnhancedInputComponent! Not binding any actions!")
;
return;
}
EI->BindAction(WidgetClickInputAction, ETriggerEvent::Started, this, &UVRWidgetInteractionComponent::OnBeginClick);
EI->BindAction(WidgetClickInputAction, ETriggerEvent::Completed, this, &UVRWidgetInteractionComponent::OnEndClick);
}
// Called every frame
void UVRWidgetInteractionComponent::TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// Disable/enable ray on hover
if (InteractionRayVisibility == EInteractionRayVisibility::VisibleOnHoverOnly)
{
if (IsOverInteractableWidget())
{
InteractionRay->SetVisibility(true);
}
else
{
InteractionRay->SetVisibility(false);
}
}
}
void UVRWidgetInteractionComponent::SetInteractionRayVisibility(EInteractionRayVisibility NewVisibility)
{
InteractionRayVisibility = NewVisibility;
InteractionRay->SetVisibility(NewVisibility == Visible);
}
// Forward the click to the WidgetInteraction
void UVRWidgetInteractionComponent::OnBeginClick(const FInputActionValue& Value)
{
PressPointerKey(EKeys::LeftMouseButton);
}
// Forward the end click to the WidgetInteraction
void UVRWidgetInteractionComponent::OnEndClick(const FInputActionValue& Value)
{
ReleasePointerKey(EKeys::LeftMouseButton);
}
void UVRWidgetInteractionComponent::CreateInteractionRay()
{
// Only create a new static mesh component if we haven't gotten one already
if (!InteractionRay)
{
// Create the new component
InteractionRay = NewObject<UStaticMeshComponent>(this);
// If we're not already attached, attach. Not sure why this is needed, taken from engine code.
if (!InteractionRay->GetAttachParent() && !InteractionRay->IsAttachedTo(this))
{
const AActor* Owner = GetOwner();
// Copied from engine code - I don't think this case will ever happen
if (!Owner || !Owner->GetWorld())
{
if (UWorld* World = GetWorld())
{
InteractionRay->RegisterComponentWithWorld(World);
InteractionRay->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
}
else
{
InteractionRay->SetupAttachment(this);
}
}
else
{
// Usual case, just attach it to ourselves.
InteractionRay->AttachToComponent(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
InteractionRay->RegisterComponent();
}
}
}
}
void UVRWidgetInteractionComponent::SetupInteractionRay()
{
// Create the InteractionRay component and attach it to us.
CreateInteractionRay();
// Setup the interaction ray.
// The static mesh reference is set in the blueprint, avoid ConstructorHelpers and hardcoded paths!
// this ray model has an inlayed cross with flipped normals so it can be seen as a cross in desktop mode
// where the right hand is attached to the head
if (InteractionRayMesh)
{
InteractionRay->SetStaticMesh(InteractionRayMesh);
}
InteractionRay->SetCastShadow(false);
// turns off collisions as the InteractionRay is only meant to visualize the ray
InteractionRay->SetCollisionProfileName(TEXT("NoCollision"));
//the ray model has a length of 100cm (and is a bit too big in Y/Z dir)
InteractionRay->SetRelativeScale3D(FVector(InteractionDistance / 100.0f, 0.5f, 0.5f));
SetInteractionRayVisibility(InteractionRayVisibility);
}
// Fill out your copyright notice in the Description page of Project Settings.
#include "Pawn/BasicVRInteractionComponent.h"
#include "Misc/Optional.h"
DEFINE_LOG_CATEGORY(LogVRInteractionComponent);
// Sets default values for this component's properties
UBasicVRInteractionComponent::UBasicVRInteractionComponent()
{
// 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;
// Setup the interaction ray.
InteractionRay = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Interaction Ray"));
InteractionRay->SetCastShadow(false);
// turns off collisions as the InteractionRay is only meant to visualize the ray
InteractionRay->SetCollisionProfileName(TEXT("NoCollision"));
// The static mesh reference is set in the blueprint, avoid ConstructorHelpers and hardcoded paths!
// this ray model has an inlayed cross with flipped normals so it can be seen as a cross in desktop mode where the right hand is attached to the head
bShowDebug = false; //otherwise the WidgetInteractionComponent debug vis is shown
InteractionSource = EWidgetInteractionSource::Custom;
//can also be kept at default (World), this way, however, we efficiently reuse the line traces
}
void UBasicVRInteractionComponent::BeginPlay()
{
Super::BeginPlay();
//WidgetInteractionComponent
InteractionDistance = MaxClickDistance;
InteractionRay->SetRelativeScale3D(FVector(MaxClickDistance / 100.0f, 0.5f, 0.5f));
//the ray model has a length of 100cm (and is a bit too big in Y/Z dir)
SetInteractionRayVisibility(InteractionRayVisibility);
}
void UBasicVRInteractionComponent::BeginInteraction()
{
if (!InteractionRayEmitter) return;
// start and end point for raytracing
const FTwoVectors StartEnd = GetHandRay(MaxClickDistance);
TOptional<FHitResult> Hit = RaytraceForFirstHit(StartEnd);
if (!Hit.IsSet())
return;
AActor* HitActor = Hit->GetActor();
//trigger interaction of WidgetInteractionComponent
SetCustomHitResult(Hit.GetValue());
//if !bCanRaytraceEveryTick, you have to click twice, since the first tick it only highlights and can't directly click
PressPointerKey(EKeys::LeftMouseButton);
}
void UBasicVRInteractionComponent::EndInteraction()
{
if (!InteractionRayEmitter) return;
//end interaction of WidgetInteractionComponent
ReleasePointerKey(EKeys::LeftMouseButton);
}
// Called every frame
void UBasicVRInteractionComponent::TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
if (!InteractionRayEmitter) return;
// only raytrace for targetable objects if bool user wants to enable this feature
if (!bCanRaytraceEveryTick)
return;
const FTwoVectors StartEnd = GetHandRay(MaxClickDistance);
TOptional<FHitResult> Hit = RaytraceForFirstHit(StartEnd);
if (!Hit.IsSet() || !Hit->GetActor())
{
if (InteractionRayVisibility == EInteractionRayVisibility::VisibleOnHoverOnly)
{
InteractionRay->SetVisibility(false);
}
return;
}
AActor* HitActor = Hit->GetActor();
// widget interaction
SetCustomHitResult(Hit.GetValue());
if (InteractionRayVisibility == EInteractionRayVisibility::VisibleOnHoverOnly)
{
if (IsOverInteractableWidget())
{
InteractionRay->SetVisibility(true);
}
else
{
InteractionRay->SetVisibility(false);
}
}
LastActorHit = HitActor; // Store the actor that was hit to have access to it in the next frame as well
}
void UBasicVRInteractionComponent::Initialize(USceneComponent* RayEmitter)
{
if (InteractionRayEmitter) return; /* Return if already initialized */
InteractionRayEmitter = RayEmitter;
InteractionRay->AttachToComponent(RayEmitter, FAttachmentTransformRules::KeepRelativeTransform);
this->AttachToComponent(RayEmitter, FAttachmentTransformRules::KeepRelativeTransform);
}
void UBasicVRInteractionComponent::SetInteractionRayVisibility(EInteractionRayVisibility NewVisibility)
{
InteractionRayVisibility = NewVisibility;
if (InteractionRay)
{
switch (InteractionRayVisibility)
{
case Visible:
InteractionRay->SetVisibility(true);
break;
case VisibleOnHoverOnly:
case Invisible:
InteractionRay->SetVisibility(false);
break;
default: ;
}
}
if (InteractionRayVisibility == EInteractionRayVisibility::VisibleOnHoverOnly && !bCanRaytraceEveryTick)
{
UE_LOG(LogVRInteractionComponent, Warning,
TEXT("VisibleOnHoverOnly needs bCanRaytraceEveryTick=true, so this is set!"));
bCanRaytraceEveryTick = true;
}
if (InteractionRayVisibility == EInteractionRayVisibility::Visible && !bCanRaytraceEveryTick)
{
UE_LOG(LogVRInteractionComponent, Warning,
TEXT(
"VisibleOnHoverOnly will need two clicks to interact with widgets if bCanRaytraceEveryTick is not set!"
));
}
}
FTwoVectors UBasicVRInteractionComponent::GetHandRay(const float Length) const
{
const FVector Start = InteractionRayEmitter->GetComponentLocation();
const FVector Direction = InteractionRayEmitter->GetForwardVector();
const FVector End = Start + Length * Direction;
return FTwoVectors(Start, End);
}
TOptional<FHitResult> UBasicVRInteractionComponent::RaytraceForFirstHit(const FTwoVectors& Ray) const
{
const FVector Start = Ray.v1;
const FVector End = Ray.v2;
// will be filled by the Line Trace Function
FHitResult Hit;
FCollisionQueryParams Params;
Params.AddIgnoredActor(GetOwner()->GetUniqueID()); // prevents actor hitting itself
if (GetWorld()->LineTraceSingleByChannel(Hit, Start, End, ECollisionChannel::ECC_Visibility, Params))
return {Hit};
else
return {};
}
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "EnhancedInputSubsystems.h" #include "EnhancedInputSubsystems.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "Pawn/VRPawnInputConfig.h"
#include "Utility/VirtualRealityUtilities.h" #include "Utility/VirtualRealityUtilities.h"
#include "MotionControllerComponent.h" #include "MotionControllerComponent.h"
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "NavigationSystem.h" #include "NavigationSystem.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "Pawn/VRPawnInputConfig.h"
#include "NiagaraFunctionLibrary.h" #include "NiagaraFunctionLibrary.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "NiagaraDataInterfaceArrayFunctionLibrary.h" #include "NiagaraDataInterfaceArrayFunctionLibrary.h"
......
// Fill out your copyright notice in the Description page of Project Settings.
#include "Pawn/VRPawnInputConfig.h"
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "GameFramework/PlayerController.h" #include "GameFramework/PlayerController.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "ILiveLinkClient.h" #include "ILiveLinkClient.h"
#include "Core/RWTHVRPlayerState.h" #include "Core/RWTHVRPlayerState.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
...@@ -14,7 +12,6 @@ ...@@ -14,7 +12,6 @@
#include "Pawn/Navigation/VRPawnMovement.h" #include "Pawn/Navigation/VRPawnMovement.h"
#include "Pawn/ReplicatedCameraComponent.h" #include "Pawn/ReplicatedCameraComponent.h"
#include "Pawn/ReplicatedMotionControllerComponent.h" #include "Pawn/ReplicatedMotionControllerComponent.h"
#include "Pawn/VRPawnInputConfig.h"
#include "Roles/LiveLinkTransformTypes.h" #include "Roles/LiveLinkTransformTypes.h"
#include "Utility/VirtualRealityUtilities.h" #include "Utility/VirtualRealityUtilities.h"
...@@ -39,9 +36,6 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial ...@@ -39,9 +36,6 @@ AVirtualRealityPawn::AVirtualRealityPawn(const FObjectInitializer& ObjectInitial
LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC")); LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC"));
LeftHand->SetupAttachment(RootComponent); LeftHand->SetupAttachment(RootComponent);
BasicVRInteraction = CreateDefaultSubobject<UBasicVRInteractionComponent>(TEXT("Basic VR Interaction"));
BasicVRInteraction->Initialize(RightHand);
} }
void AVirtualRealityPawn::Tick(float DeltaSeconds) void AVirtualRealityPawn::Tick(float DeltaSeconds)
...@@ -100,16 +94,6 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput ...@@ -100,16 +94,6 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput
// There is probably a checkbox or way of spawning that prevents that in a better way that this, change if found. // There is probably a checkbox or way of spawning that prevents that in a better way that this, change if found.
PlayerController->SetControlRotation(FRotator::ZeroRotator); PlayerController->SetControlRotation(FRotator::ZeroRotator);
const ULocalPlayer* LP = PlayerController->GetLocalPlayer();
UEnhancedInputLocalPlayerSubsystem* InputSubsystem = LP
? LP->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>()
: nullptr;
if (!InputSubsystem)
{
UE_LOG(Toolkit, Error, TEXT("[VirtualRealiytPawn.cpp] InputSubsystem IS NOT VALID"));
return;
}
SetupMotionControllerSources(); SetupMotionControllerSources();
// Should not do this here but on connection or on possess I think. // Should not do this here but on connection or on possess I think.
...@@ -135,19 +119,6 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput ...@@ -135,19 +119,6 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput
PlayerController->bEnableMouseOverEvents = true; PlayerController->bEnableMouseOverEvents = true;
} }
InputSubsystem->ClearAllMappings();
// add Input Mapping context
InputSubsystem->AddMappingContext(IMCBase, 0);
UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(PlayerInputComponent);
// old function bindings for grabbing and releasing
EI->BindAction(Fire, ETriggerEvent::Started, this, &AVirtualRealityPawn::OnBeginFire);
EI->BindAction(Fire, ETriggerEvent::Completed, this, &AVirtualRealityPawn::OnEndFire);
EI->BindAction(ToggleNavigationMode, ETriggerEvent::Started, this, &AVirtualRealityPawn::OnToggleNavigationMode);
// Set up mappings on input extension components, need to do this nicely // Set up mappings on input extension components, need to do this nicely
for (UActorComponent* Comp : GetComponentsByInterface(UInputExtensionInterface::StaticClass())) for (UActorComponent* Comp : GetComponentsByInterface(UInputExtensionInterface::StaticClass()))
...@@ -274,44 +245,6 @@ void AVirtualRealityPawn::SetCameraOffset() const ...@@ -274,44 +245,6 @@ void AVirtualRealityPawn::SetCameraOffset() const
HeadCameraComponent->SetWorldLocationAndRotation(Location, Rotation); HeadCameraComponent->SetWorldLocationAndRotation(Location, Rotation);
} }
// legacy grabbing
void AVirtualRealityPawn::OnBeginFire(const FInputActionValue& Value)
{
UE_LOG(LogTemp, Warning, TEXT("BeginFire"));
BasicVRInteraction->BeginInteraction();
}
// legacy grabbing
void AVirtualRealityPawn::OnEndFire(const FInputActionValue& Value)
{
UE_LOG(Toolkit, Log, TEXT("EndFire"));
BasicVRInteraction->EndInteraction();
}
void AVirtualRealityPawn::OnToggleNavigationMode(const FInputActionValue& Value)
{
switch (PawnMovement->NavigationMode)
{
case EVRNavigationModes::NAV_FLY:
PawnMovement->NavigationMode = EVRNavigationModes::NAV_WALK;
UE_LOG(Toolkit, Log, TEXT("Changed Nav mode to WALK"));
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;
default:
PawnMovement->NavigationMode = EVRNavigationModes::NAV_WALK;
UE_LOG(Toolkit, Log, TEXT("Changed Nav mode to WALK"));
break;
}
}
void AVirtualRealityPawn::ApplyLiveLinkTransform(const FTransform& Transform, void AVirtualRealityPawn::ApplyLiveLinkTransform(const FTransform& Transform,
const FLiveLinkTransformStaticData& StaticData) const const FLiveLinkTransformStaticData& StaticData) const
{ {
......
...@@ -4,11 +4,8 @@ ...@@ -4,11 +4,8 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Components/WidgetInteractionComponent.h" #include "Components/WidgetInteractionComponent.h"
#include "BasicVRInteractionComponent.generated.h" #include "Pawn/InputExtensionInterface.h"
#include "VRWidgetInteractionComponent.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(LogVRInteractionComponent, Log, All);
class UGrabbingBehaviorComponent;
UENUM() UENUM()
enum EInteractionRayVisibility enum EInteractionRayVisibility
...@@ -21,70 +18,45 @@ enum EInteractionRayVisibility ...@@ -21,70 +18,45 @@ enum EInteractionRayVisibility
}; };
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) UCLASS(Blueprintable, Abstract, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class RWTHVRTOOLKIT_API UBasicVRInteractionComponent : public UWidgetInteractionComponent class RWTHVRTOOLKIT_API UVRWidgetInteractionComponent : public UWidgetInteractionComponent,
public IInputExtensionInterface
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
// Sets default values for this component's properties UVRWidgetInteractionComponent();
UBasicVRInteractionComponent();
virtual void BeginPlay() override; virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override; FActorComponentTickFunction* ThisTickFunction) override;
UFUNCTION(BlueprintCallable)
void BeginInteraction();
UFUNCTION(BlueprintCallable)
void EndInteraction();
UFUNCTION(BlueprintCallable)
void Initialize(USceneComponent* RayEmitter);
UFUNCTION(BlueprintCallable, BlueprintPure)
AActor* GetGrabbedActor() const { return GrabbedActor; }
UFUNCTION(BlueprintCallable, BlueprintPure)
USceneComponent* GetInteractionRayEmitter() const { return InteractionRayEmitter; }
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
void SetInteractionRayVisibility(EInteractionRayVisibility NewVisibility); void SetInteractionRayVisibility(EInteractionRayVisibility NewVisibility);
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Interaction")
UStaticMeshComponent* InteractionRay;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxGrabDistance = 50;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float MaxClickDistance = 500;
// Enable this if you want to interact with Targetable classes or use EInteractionRayVisibility::VisibleOnHoverOnly
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
bool bCanRaytraceEveryTick = false; UStaticMesh* InteractionRayMesh;
UPROPERTY(BlueprintReadOnly)
UStaticMeshComponent* InteractionRay;
UPROPERTY(EditAnywhere) UPROPERTY(EditAnywhere)
TEnumAsByte<EInteractionRayVisibility> InteractionRayVisibility = EInteractionRayVisibility::Invisible; TEnumAsByte<EInteractionRayVisibility> InteractionRayVisibility = EInteractionRayVisibility::Invisible;
private: UPROPERTY(EditDefaultsOnly, Category = "Input")
/* Holding a reference to the actor that is currently being grabbed */ class UInputMappingContext* IMCWidgetInteraction;
UPROPERTY()
AActor* GrabbedActor;
/* Holds a reference to the grabbed actors physics simulating component if there was one*/ UPROPERTY(EditAnywhere, Category = "Input")
UPROPERTY() class UInputAction* WidgetClickInputAction;
UPrimitiveComponent* ComponentSimulatingPhysics = nullptr;
UPROPERTY() private:
USceneComponent* InteractionRayEmitter = nullptr; UFUNCTION()
void OnBeginClick(const FInputActionValue& Value);
/* Stores the reference of the Actor that was hit in the last frame*/ UFUNCTION()
UPROPERTY() void OnEndClick(const FInputActionValue& Value);
AActor* LastActorHit = nullptr;
FTwoVectors GetHandRay(float Length) const; void CreateInteractionRay();
TOptional<FHitResult> RaytraceForFirstHit(const FTwoVectors& Ray) const; void SetupInteractionRay();
}; };
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "InputAction.h"
#include "Engine/DataAsset.h"
#include "VRPawnInputConfig.generated.h"
/**
*
*/
UCLASS()
class RWTHVRTOOLKIT_API UVRPawnInputConfig : public UDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* MoveUp;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* DesktopRotation;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* Fire;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* Grab;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* Move;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* Turn;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* ToggleNavigationMode;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* GrabLeft;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
UInputAction* GrabRight;
};
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#pragma once #pragma once
#include "BasicVRInteractionComponent.h"
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "LiveLinkRole.h" #include "LiveLinkRole.h"
#include "Pawn/Navigation/VRPawnMovement.h" #include "Pawn/Navigation/VRPawnMovement.h"
...@@ -35,10 +34,6 @@ public: ...@@ -35,10 +34,6 @@ public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|MotionControllers") UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|MotionControllers")
UMotionControllerComponent* LeftHand; UMotionControllerComponent* LeftHand;
/* Interaction */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Interaction")
UBasicVRInteractionComponent* BasicVRInteraction;
/* Movement */ /* Movement */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Movement") UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Movement")
UVRPawnMovement* PawnMovement; UVRPawnMovement* PawnMovement;
...@@ -88,26 +83,6 @@ protected: ...@@ -88,26 +83,6 @@ protected:
/* Helper function that applies the LiveLink data to this component. Taken from the LiveLink Transform Controller. */ /* Helper function that applies the LiveLink data to this component. Taken from the LiveLink Transform Controller. */
void ApplyLiveLinkTransform(const FTransform& Transform, const FLiveLinkTransformStaticData& StaticData) const; void ApplyLiveLinkTransform(const FTransform& Transform, const FLiveLinkTransformStaticData& StaticData) const;
/* Interaction */
UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction")
void OnBeginFire(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable, Category = "Pawn|Interaction")
void OnEndFire(const FInputActionValue& Value);
UFUNCTION(BlueprintCallable)
void OnToggleNavigationMode(const FInputActionValue& Value);
/* Input */
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pawn|Input")
UInputMappingContext* IMCBase;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pawn|Input")
UInputAction* Fire;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Pawn|Input")
UInputAction* ToggleNavigationMode;
/* Fixes camera rotation in desktop mode. */ /* Fixes camera rotation in desktop mode. */
void SetCameraOffset() const; void SetCameraOffset() const;
void UpdateRightHandForDesktopInteraction() const; void UpdateRightHandForDesktopInteraction() const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment