diff --git a/.gitignore b/.gitignore index d114181..8fa8a52 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ Project/.vsconfig *.target *.modules Project/.idea + +Project/Saved/Screenshots +*/Binaries/Win64/*.patch_*.* diff --git a/Project/Binaries/Win64/UnrealEditor-Gasa.dll b/Project/Binaries/Win64/UnrealEditor-Gasa.dll index 3efd3cd..d6e19fb 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 ce64c5a..71d7084 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-Gasa.pdb and b/Project/Binaries/Win64/UnrealEditor-Gasa.pdb differ diff --git a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll index 66c2159..2654f7d 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll and b/Project/Binaries/Win64/UnrealEditor-GasaEditor.dll differ diff --git a/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb b/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb index d463302..639b3e3 100644 Binary files a/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb and b/Project/Binaries/Win64/UnrealEditor-GasaEditor.pdb differ diff --git a/Project/Config/DefaultEngine.ini b/Project/Config/DefaultEngine.ini index 9a69e01..0feed8b 100644 --- a/Project/Config/DefaultEngine.ini +++ b/Project/Config/DefaultEngine.ini @@ -3,6 +3,7 @@ [/Script/EngineSettings.GameMapsSettings] GameDefaultMap=/Game/Levels/StartupMap.StartupMap EditorStartupMap=/Game/Levels/StartupMap.StartupMap +GlobalDefaultGameMode=/Game/Core/Game/BP_GameMode.BP_GameMode_C [/Script/WindowsTargetPlatform.WindowsTargetSettings] DefaultGraphicsRHI=DefaultGraphicsRHI_DX12 diff --git a/Project/Content/Core/Actors/ABP_PlayerCharacter.uasset b/Project/Content/Core/Actors/ABP_PlayerCharacter.uasset index f0d73ff..57529b5 100644 --- a/Project/Content/Core/Actors/ABP_PlayerCharacter.uasset +++ b/Project/Content/Core/Actors/ABP_PlayerCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cb3804c08463945f20652035c389d2c2a1c9eab7d096e9338e867b12f0fc6fa6 -size 109325 +oid sha256:b300fcad406525f13b818b194210ebc6e701c92b247313b8c011471414445a7a +size 156522 diff --git a/Project/Content/Core/Actors/BP_PlayerCharacter.uasset b/Project/Content/Core/Actors/BP_PlayerCharacter.uasset index 7c18ae6..d3df139 100644 --- a/Project/Content/Core/Actors/BP_PlayerCharacter.uasset +++ b/Project/Content/Core/Actors/BP_PlayerCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3e4feebc4d095ff9b1f0139cb2acb6da1a6416d9d80ea4b786f6053ae78bfc00 -size 24358 +oid sha256:eee880ae4c285f850aae481e3a91c55df0691ce400a97b117490079bfdb79da2 +size 25156 diff --git a/Project/Content/Core/Game/BP_GameMode.uasset b/Project/Content/Core/Game/BP_GameMode.uasset new file mode 100644 index 0000000..c274f5e --- /dev/null +++ b/Project/Content/Core/Game/BP_GameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:851cedc71dffcad780698b7b11c55434694186420d7f50264aa66416742b00ea +size 20902 diff --git a/Project/Content/Levels/StartupMap.umap b/Project/Content/Levels/StartupMap.umap index 3296cac..ef4f549 100644 --- a/Project/Content/Levels/StartupMap.umap +++ b/Project/Content/Levels/StartupMap.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:85039dd780a2bdc572ee0161995beba6712ca752f5f85d432ad34769168c2702 -size 38313 +oid sha256:5ec89d7ce1fc847ade7513953f2ae93e897711775e0e7e7d64ad98c8c1513e18 +size 40039 diff --git a/Project/Source/Gasa/Character/GasaCharacter.cpp b/Project/Source/Gasa/Character/GasaCharacter.cpp index 81ecec4..9990966 100644 --- a/Project/Source/Gasa/Character/GasaCharacter.cpp +++ b/Project/Source/Gasa/Character/GasaCharacter.cpp @@ -1,11 +1,41 @@ #include "GasaCharacter.h" +#include "Camera/CameraComponent.h" +#include "GameFramework/CharacterMovementComponent.h" +#include "GameFramework/SpringArmComponent.h" + AGasaCharacter::AGasaCharacter() { PrimaryActorTick.bCanEverTick = false; + UCharacterMovementComponent* + Movement = GetCharacterMovement(); + Movement->bOrientRotationToMovement = true; + Movement->bConstrainToPlane = true; + Movement->bSnapToPlaneAtStart = true; + Movement->RotationRate = FRotator(0.0, 400.f, 0.0); + + bUseControllerRotationPitch = false; + bUseControllerRotationRoll = false; + bUseControllerRotationYaw = false; + + USceneComponent* root_component = GetRootComponent(); + USkeletalMeshComponent* mesh = GetMesh(); + + CamSpringArm = CreateDefaultSubobject("Camera Spring Arm"); + CamSpringArm->SetupAttachment(root_component); + CamSpringArm->SetRelativeRotation( FQuat::MakeFromEuler(FVector(0.0, -35.0, 0.0))); + CamSpringArm->TargetArmLength = 400.0f; + + CamSpringArm->bInheritPitch = false; + CamSpringArm->bInheritYaw = false; + CamSpringArm->bInheritRoll = false; + + Camera = CreateDefaultSubobject("Camera"); + Camera->SetupAttachment(CamSpringArm); + Weapon = CreateDefaultSubobject("Weapon"); - Weapon->SetupAttachment(GetMesh(), FName("WeaponAttach")); + Weapon->SetupAttachment(mesh, FName("WeaponAttach")); Weapon->SetCollisionEnabled(ECollisionEnabled::NoCollision); } diff --git a/Project/Source/Gasa/Character/GasaCharacter.h b/Project/Source/Gasa/Character/GasaCharacter.h index a310dd9..1d76696 100644 --- a/Project/Source/Gasa/Character/GasaCharacter.h +++ b/Project/Source/Gasa/Character/GasaCharacter.h @@ -1,5 +1,6 @@ #pragma once +#include "GasaCommon.h" #include "GameFramework/Character.h" #include "GasaCharacter.generated.h" @@ -9,6 +10,14 @@ class GASA_API AGasaCharacter : public ACharacter { GENERATED_BODY() public: +#pragma region Camera + UPROPERTY(EditAnywhere, Category="Camera") + UCameraComponent* Camera; + + UPROPERTY(EditAnywhere, Category="Camera") + USpringArmComponent* CamSpringArm; +#pragma endregion Camera + #pragma region Combat UPROPERTY(EditAnywhere, Category="Combat") TObjectPtr Weapon; diff --git a/Project/Source/Gasa/Gasa.Build.cs b/Project/Source/Gasa/Gasa.Build.cs index c277120..8745e41 100644 --- a/Project/Source/Gasa/Gasa.Build.cs +++ b/Project/Source/Gasa/Gasa.Build.cs @@ -55,6 +55,6 @@ public class Gasa : ModuleRules } #endregion Plugins - PublicIncludePathModuleNames.Add("Gasa"); + PublicIncludePaths.Add("Gasa"); } } diff --git a/Project/Source/Gasa/GasaCommon.h b/Project/Source/Gasa/GasaCommon.h index b27a535..53c28d4 100644 --- a/Project/Source/Gasa/GasaCommon.h +++ b/Project/Source/Gasa/GasaCommon.h @@ -2,6 +2,8 @@ #include "CoreMinimal.h" // #define private protected +class UCameraComponent; class UInputAction; struct FInputActionValue; class UInputMappingContext; +class USpringArmComponent; diff --git a/Project/Source/Gasa/GasaGameMode.cpp b/Project/Source/Gasa/GasaGameMode.cpp new file mode 100644 index 0000000..67304d3 --- /dev/null +++ b/Project/Source/Gasa/GasaGameMode.cpp @@ -0,0 +1,2 @@ +#include "GasaGameMode.h" + diff --git a/Project/Source/Gasa/GasaGameMode.h b/Project/Source/Gasa/GasaGameMode.h new file mode 100644 index 0000000..7fa00d4 --- /dev/null +++ b/Project/Source/Gasa/GasaGameMode.h @@ -0,0 +1,11 @@ +#pragma once +#include "GameFramework/GameMode.h" + +#include "GasaGameMode.generated.h" + +UCLASS(Blueprintable) +class GASA_API AGasaGameMode : public AGameMode +{ + GENERATED_BODY() +public: +}; diff --git a/Project/Source/Gasa/GasaPlayerController.cpp b/Project/Source/Gasa/GasaPlayerController.cpp index 18b8428..ed99d83 100644 --- a/Project/Source/Gasa/GasaPlayerController.cpp +++ b/Project/Source/Gasa/GasaPlayerController.cpp @@ -11,6 +11,11 @@ AGasaPlayerController::AGasaPlayerController() void AGasaPlayerController::Move(FInputActionValue const& ActionValue) { + APawn* pawn = GetPawn(); + if (pawn == nullptr ) + return; + +// Note(Ed): I did the follow optimization for practice, they are completely unnecessary for this context. #if 0 FVector2D AxisV = ActionValue.Get(); FRotator ControlRot = GetControlRotation(); @@ -19,31 +24,31 @@ void AGasaPlayerController::Move(FInputActionValue const& ActionValue) 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); - } + PPawn->AddMovementInput(FwdDir, AxisV.Y); + PPawn->AddMovementInput(RightDir, AxisV.X); #else FVector2f AxisV = FVector2f(ActionValue.Get()); - FQuat // FQuat isomorphic to FRotor (Hypothetical Def) - ControlRotor = GetControlRotation().Quaternion(); + + FQuat4f // FQuat isomorphic to FRotor (Hypothetical Def) + ControlRotor = FQuat4f(GetControlRotation().Quaternion()); // ControlRotor.Normalize(); // The Quaternion should always be a versor with UE... - FQuat4f - YawRotor = FQuat4f(FVector3f::UpVector, ControlRotor.GetAngle()); + FVector3f HorizontalForward = ControlRotor.RotateVector(FVector3f::ForwardVector); + // HorizontalForward.Normalize(); + + // TODO(Ed): Profile which is faster just to know... (atan2 vs FindBetweenVectors) + // HorizontalForward.Z = 0; + // FQuat4f + // YawRotor = FQuat4f::FindBetweenVectors(FVector3f::ForwardVector, HorizontalForward); // YawRotor.Normalize(); // The Quaternion should always be a versor with UE... - FVector3f FwdDir = YawRotor.RotateVector(FVector3f::ForwardVector); - FVector3f RightDir = YawRotor.RotateVector(FVector3f::RightVector); + // Need only one axis of rotation so this might be a possible optimization + float YawAngle = FMath::Atan2(HorizontalForward.Y, HorizontalForward.X); + FQuat4f YawRotor = FQuat4f(FVector3f::UpVector, YawAngle); - APawn* PPawn = GetPawn(); - if (PPawn) - { - PPawn->AddMovementInput(FVector(FwdDir), AxisV.Y); - PPawn->AddMovementInput(FVector(RightDir), AxisV.X); - } + // Rotate the combined input by the yaw rotor to get the movement direction + FVector MoveDir = (FVector) YawRotor.RotateVector( FVector3f(AxisV.Y, AxisV.X, 0.f)); + pawn->AddMovementInput( MoveDir ); #endif }