Movement Input
This commit is contained in:
parent
6d799a498f
commit
9cf0e05c82
Binary file not shown.
Binary file not shown.
@ -1,5 +1,7 @@
|
|||||||
// #define private protected
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
// #define private protected
|
||||||
|
|
||||||
class UInputMappingContext;
|
class UInputAction;
|
||||||
|
struct FInputActionValue;
|
||||||
|
class UInputMappingContext;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "GasaPlayerController.h"
|
#include "GasaPlayerController.h"
|
||||||
|
|
||||||
#include "Engine/LocalPlayer.h"
|
#include "Engine/LocalPlayer.h"
|
||||||
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
|
|
||||||
AGasaPlayerController::AGasaPlayerController()
|
AGasaPlayerController::AGasaPlayerController()
|
||||||
@ -8,6 +9,58 @@ AGasaPlayerController::AGasaPlayerController()
|
|||||||
bReplicates = true;
|
bReplicates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AGasaPlayerController::Move(FInputActionValue const& ActionValue)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
FVector2D AxisV = ActionValue.Get<FVector2D>();
|
||||||
|
FRotator ControlRot = GetControlRotation();
|
||||||
|
FRotator YawRot = FRotator(0.f, ControlRot.Yaw, 0.f);
|
||||||
|
|
||||||
|
FVector FwdDir = FRotationMatrix(YawRot).GetUnitAxis(EAxis::X);
|
||||||
|
FVector RightDir = FRotationMatrix(YawRot).GetUnitAxis(EAxis::Y);
|
||||||
|
|
||||||
|
APawn* Pawn = GetPawn<APawn>();
|
||||||
|
if (Pawn)
|
||||||
|
{
|
||||||
|
Pawn->AddMovementInput(FwdDir, AxisV.Y);
|
||||||
|
Pawn->AddMovementInput(RightDir, AxisV.X);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
FVector2f AxisV = FVector2f(ActionValue.Get<FVector2D>());
|
||||||
|
FQuat // FQuat isomorphic to FRotor (Hypothetical Def)
|
||||||
|
ControlRotor = GetControlRotation().Quaternion();
|
||||||
|
// ControlRotor.Normalize(); // The Quaternion should always be a versor with UE...
|
||||||
|
|
||||||
|
FQuat4f
|
||||||
|
YawRotor = FQuat4f(FVector3f::UpVector, ControlRotor.GetAngle());
|
||||||
|
// YawRotor.Normalize(); // The Quaternion should always be a versor with UE...
|
||||||
|
|
||||||
|
FVector3f FwdDir = YawRotor.RotateVector(FVector3f::ForwardVector);
|
||||||
|
FVector3f RightDir = YawRotor.RotateVector(FVector3f::RightVector);
|
||||||
|
|
||||||
|
APawn* PPawn = GetPawn<APawn>();
|
||||||
|
if (PPawn)
|
||||||
|
{
|
||||||
|
PPawn->AddMovementInput(FVector(FwdDir), AxisV.Y);
|
||||||
|
PPawn->AddMovementInput(FVector(RightDir), AxisV.X);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region PlayerController
|
||||||
|
void AGasaPlayerController::SetupInputComponent()
|
||||||
|
{
|
||||||
|
Super::SetupInputComponent();
|
||||||
|
|
||||||
|
UEnhancedInputComponent*
|
||||||
|
EIC = CastChecked<UEnhancedInputComponent>(InputComponent);
|
||||||
|
{
|
||||||
|
EIC->BindAction(IA_Move, ETriggerEvent::Triggered, this, &ThisClass::Move);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#pragma endregion PlayerController
|
||||||
|
|
||||||
|
#pragma region Actor
|
||||||
void AGasaPlayerController::BeginPlay()
|
void AGasaPlayerController::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
@ -26,3 +79,4 @@ void AGasaPlayerController::BeginPlay()
|
|||||||
SetInputMode(MouseMode);
|
SetInputMode(MouseMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma endregion Actor
|
||||||
|
@ -1,18 +1,34 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "GasaCommon.h"
|
#include "GasaCommon.h"
|
||||||
|
#include "GameFramework/PlayerController.h"
|
||||||
|
|
||||||
#include "GasaPlayerController.generated.h"
|
#include "GasaPlayerController.generated.h"
|
||||||
|
|
||||||
|
|
||||||
UCLASS(Blueprintable)
|
UCLASS(Blueprintable)
|
||||||
class GASA_API AGasaPlayerController : public APlayerController
|
class GASA_API AGasaPlayerController : public APlayerController
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#pragma region Input
|
||||||
|
UPROPERTY(EditAnywhere, Category="Input")
|
||||||
TObjectPtr<UInputMappingContext> IMC;
|
TObjectPtr<UInputMappingContext> IMC;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category="Input")
|
||||||
|
TObjectPtr<UInputAction> IA_Move;
|
||||||
|
#pragma endregion Input
|
||||||
|
|
||||||
AGasaPlayerController();
|
AGasaPlayerController();
|
||||||
|
|
||||||
|
void Move(FInputActionValue const& ActionValue);
|
||||||
|
|
||||||
|
#pragma region PlayerController
|
||||||
|
void SetupInputComponent() override;
|
||||||
|
#pragma endregion PlayerController
|
||||||
|
|
||||||
|
#pragma region Actor
|
||||||
void BeginPlay() override;
|
void BeginPlay() override;
|
||||||
|
#pragma endregion Actor
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user