diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index 2bc4451..3efd3cd 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.dll and b/Project/Binaries/Win64/UnrealEditor-Gasa.dll differ diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb index 89e1af9..ce64c5a 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb and b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb differ diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index 083591c..b27a535 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -1,5 +1,7 @@ -// #define private protected - + #include "CoreMinimal.h" +// #define private protected -class UInputMappingContext; \ No newline at end of file +class UInputAction; +struct FInputActionValue; +class UInputMappingContext; diff --git a/Project/Source/Gasa/GasaPlayerController.cpp b/Project/Source/Gasa/GasaPlayerController.cpp index 7a78874..18b8428 100644 --- a/Project/Source/Gasa/GasaPlayerController.cpp +++ b/Project/Source/Gasa/GasaPlayerController.cpp @@ -1,6 +1,7 @@ #include "GasaPlayerController.h" #include "Engine/LocalPlayer.h" +#include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" AGasaPlayerController::AGasaPlayerController() @@ -8,6 +9,58 @@ AGasaPlayerController::AGasaPlayerController() bReplicates = true; } +void AGasaPlayerController::Move(FInputActionValue const& ActionValue) +{ +#if 0 + FVector2D AxisV = ActionValue.Get(); + 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(); + if (Pawn) + { + Pawn->AddMovementInput(FwdDir, AxisV.Y); + Pawn->AddMovementInput(RightDir, AxisV.X); + } +#else + FVector2f AxisV = FVector2f(ActionValue.Get()); + 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(); + 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(InputComponent); + { + EIC->BindAction(IA_Move, ETriggerEvent::Triggered, this, &ThisClass::Move); + } +} +#pragma endregion PlayerController + +#pragma region Actor void AGasaPlayerController::BeginPlay() { Super::BeginPlay(); @@ -26,3 +79,4 @@ void AGasaPlayerController::BeginPlay() SetInputMode(MouseMode); } } +#pragma endregion Actor diff --git a/Project/Source/Gasa/GasaPlayerController.h b/Project/Source/Gasa/GasaPlayerController.h index 2135a7d..176ff77 100644 --- a/Project/Source/Gasa/GasaPlayerController.h +++ b/Project/Source/Gasa/GasaPlayerController.h @@ -1,18 +1,34 @@ #pragma once #include "GasaCommon.h" +#include "GameFramework/PlayerController.h" #include "GasaPlayerController.generated.h" + UCLASS(Blueprintable) class GASA_API AGasaPlayerController : public APlayerController { GENERATED_BODY() public: +#pragma region Input + UPROPERTY(EditAnywhere, Category="Input") TObjectPtr IMC; + + UPROPERTY(EditAnywhere, Category="Input") + TObjectPtr IA_Move; +#pragma endregion Input AGasaPlayerController(); + void Move(FInputActionValue const& ActionValue); + +#pragma region PlayerController + void SetupInputComponent() override; +#pragma endregion PlayerController + +#pragma region Actor void BeginPlay() override; +#pragma endregion Actor };