From 8e7ca53d569d5237215e22adffefd6aba6e207f8 Mon Sep 17 00:00:00 2001 From: Emilie Schott <43524962+EmilieSchott@users.noreply.github.com> Date: Sun, 19 Jan 2025 16:27:13 +0100 Subject: [PATCH] Added Move Controls --- Binaries/Win64/LegumeMixEditor.target | 32 +++++++-------- Binaries/Win64/UnrealEditor-LegumeMix.exp | 4 +- Binaries/Win64/UnrealEditor-LegumeMix.pdb | 4 +- Config/DefaultEngine.ini | 1 + Content/Legumix/BP_GameMode.uasset | 3 ++ Content/Legumix/Player/BP_Player.uasset | 3 ++ .../Legumix/Player/BP_PlayerController.uasset | 3 ++ Content/Legumix/Player/Input/IA_Jump.uasset | 3 ++ Content/Legumix/Player/Input/IA_Look.uasset | 3 ++ Content/Legumix/Player/Input/IA_Move.uasset | 3 ++ Content/Legumix/Player/Input/IA_Shoot.uasset | 3 ++ .../Legumix/Player/Input/IMC_Default.uasset | 3 ++ LegumeMix.uproject | 5 ++- Source/LegumeMix/Private/Player/LMPlayer.cpp | 34 +++++++++++++++ .../Private/Player/LMPlayerController.cpp | 27 ++++++++++++ Source/LegumeMix/Public/Player/LMPlayer.h | 29 +++++++++++++ .../Public/Player/LMPlayerController.h | 41 +++++++++++++++++++ 17 files changed, 180 insertions(+), 21 deletions(-) create mode 100644 Content/Legumix/BP_GameMode.uasset create mode 100644 Content/Legumix/Player/BP_Player.uasset create mode 100644 Content/Legumix/Player/BP_PlayerController.uasset create mode 100644 Content/Legumix/Player/Input/IA_Jump.uasset create mode 100644 Content/Legumix/Player/Input/IA_Look.uasset create mode 100644 Content/Legumix/Player/Input/IA_Move.uasset create mode 100644 Content/Legumix/Player/Input/IA_Shoot.uasset create mode 100644 Content/Legumix/Player/Input/IMC_Default.uasset create mode 100644 Source/LegumeMix/Private/Player/LMPlayer.cpp create mode 100644 Source/LegumeMix/Private/Player/LMPlayerController.cpp create mode 100644 Source/LegumeMix/Public/Player/LMPlayer.h create mode 100644 Source/LegumeMix/Public/Player/LMPlayerController.h diff --git a/Binaries/Win64/LegumeMixEditor.target b/Binaries/Win64/LegumeMixEditor.target index 24b287c..73af617 100644 --- a/Binaries/Win64/LegumeMixEditor.target +++ b/Binaries/Win64/LegumeMixEditor.target @@ -21,6 +21,18 @@ "BuildId": "37670630" }, "BuildProducts": [ + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll", + "Type": "DynamicLibrary" + }, + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb", + "Type": "SymbolFile" + }, + { + "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules", + "Type": "RequiredResource" + }, { "Path": "$(EngineDir)/Binaries/ThirdParty/USD/UsdResources/Win64/plugins/ar/resources/plugInfo.json", "Type": "RequiredResource" @@ -4872,21 +4884,13 @@ { "Path": "$(EngineDir)/Plugins/XGEController/Binaries/Win64/UnrealEditor.modules", "Type": "RequiredResource" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.dll", - "Type": "DynamicLibrary" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor-LegumeMix.pdb", - "Type": "SymbolFile" - }, - { - "Path": "$(ProjectDir)/Binaries/Win64/UnrealEditor.modules", - "Type": "RequiredResource" } ], "RuntimeDependencies": [ + { + "Path": "$(ProjectDir)/LegumeMix.uproject", + "Type": "UFS" + }, { "Path": "$(EngineDir)/Binaries/ThirdParty/DbgHelp/dbghelp.dll", "Type": "NonUFS" @@ -30614,10 +30618,6 @@ { "Path": "$(EngineDir)/Plugins/XGEController/XGEController.uplugin", "Type": "UFS" - }, - { - "Path": "$(ProjectDir)/LegumeMix.uproject", - "Type": "UFS" } ], "BuildPlugins": [ diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.exp b/Binaries/Win64/UnrealEditor-LegumeMix.exp index d2dbd08..1910de7 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.exp +++ b/Binaries/Win64/UnrealEditor-LegumeMix.exp @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:06dce05f654f29688691f3f4cee2a54b1d490d7a3739487811fd83b98725bfe4 -size 821 +oid sha256:0c03fc5302b7851ea3988908bbc9388e482a3689c8916355c68d2342131ed7dd +size 11035 diff --git a/Binaries/Win64/UnrealEditor-LegumeMix.pdb b/Binaries/Win64/UnrealEditor-LegumeMix.pdb index 841fbe7..6074212 100644 --- a/Binaries/Win64/UnrealEditor-LegumeMix.pdb +++ b/Binaries/Win64/UnrealEditor-LegumeMix.pdb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e84b4b7673f86d993c6008878a4fe2cf485eb54beb76bafa7f6a9cbe068df991 -size 57430016 +oid sha256:4bd9e85e6cbd527b51099c9ee1800a227ff79bda18d26ac40b665732b99cbd36 +size 59527168 diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 31200eb..8418e17 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -2,6 +2,7 @@ [/Script/EngineSettings.GameMapsSettings] GameDefaultMap=/Engine/Maps/Templates/OpenWorld +GlobalDefaultGameMode=/Game/Legumix/BP_GameMode.BP_GameMode_C [/Script/Engine.RendererSettings] r.AllowStaticLighting=False diff --git a/Content/Legumix/BP_GameMode.uasset b/Content/Legumix/BP_GameMode.uasset new file mode 100644 index 0000000..5f71003 --- /dev/null +++ b/Content/Legumix/BP_GameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffcd01b1a1fbc3def3c8451957cb4dc49d6529b1ea90ba3303bc53d2bd2f22ef +size 20699 diff --git a/Content/Legumix/Player/BP_Player.uasset b/Content/Legumix/Player/BP_Player.uasset new file mode 100644 index 0000000..e6a31fd --- /dev/null +++ b/Content/Legumix/Player/BP_Player.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6fedb5b5313e07449e4484a6a04d406fbba2b1f881663e8e8f49dde15e092e5b +size 33343 diff --git a/Content/Legumix/Player/BP_PlayerController.uasset b/Content/Legumix/Player/BP_PlayerController.uasset new file mode 100644 index 0000000..0621c64 --- /dev/null +++ b/Content/Legumix/Player/BP_PlayerController.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:405ca21288778bca44cf90e4b0f221cbd80ccad8b3e2d0b5b5828959e0c8f4d8 +size 20808 diff --git a/Content/Legumix/Player/Input/IA_Jump.uasset b/Content/Legumix/Player/Input/IA_Jump.uasset new file mode 100644 index 0000000..6e1e93e --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Jump.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:efc996b537518a58a24af4b53d9826c0f17fa892875c855971429153d226c08d +size 1382 diff --git a/Content/Legumix/Player/Input/IA_Look.uasset b/Content/Legumix/Player/Input/IA_Look.uasset new file mode 100644 index 0000000..006405d --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Look.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1ec20ab715444a17a60404d1f7426fbeeba8d6a79cae4548925d7f55c948d541 +size 1578 diff --git a/Content/Legumix/Player/Input/IA_Move.uasset b/Content/Legumix/Player/Input/IA_Move.uasset new file mode 100644 index 0000000..55a37dd --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Move.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9ab58db0fc15fd47a30cbab3e2bfdcad48244d056dda292f3f0ce5914bb9b83f +size 1578 diff --git a/Content/Legumix/Player/Input/IA_Shoot.uasset b/Content/Legumix/Player/Input/IA_Shoot.uasset new file mode 100644 index 0000000..4e8c799 --- /dev/null +++ b/Content/Legumix/Player/Input/IA_Shoot.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:08c6295c098e9397372285219b1b5d37bc166e40d82eeeb81766dd85d10e91b9 +size 1387 diff --git a/Content/Legumix/Player/Input/IMC_Default.uasset b/Content/Legumix/Player/Input/IMC_Default.uasset new file mode 100644 index 0000000..48eb909 --- /dev/null +++ b/Content/Legumix/Player/Input/IMC_Default.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5c461dc8431f38a282d68d1c0d1f3ff4aff642593227ddda4ea00b6ef54f394b +size 6714 diff --git a/LegumeMix.uproject b/LegumeMix.uproject index 33f1bc2..2356227 100644 --- a/LegumeMix.uproject +++ b/LegumeMix.uproject @@ -7,7 +7,10 @@ { "Name": "LegumeMix", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ diff --git a/Source/LegumeMix/Private/Player/LMPlayer.cpp b/Source/LegumeMix/Private/Player/LMPlayer.cpp new file mode 100644 index 0000000..2bcea73 --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMPlayer.cpp @@ -0,0 +1,34 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Player/LMPlayer.h" + +// Sets default values +ALMPlayer::ALMPlayer() +{ + // Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +// Called when the game starts or when spawned +void ALMPlayer::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void ALMPlayer::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + +} + +// Called to bind functionality to input +void ALMPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + +} + diff --git a/Source/LegumeMix/Private/Player/LMPlayerController.cpp b/Source/LegumeMix/Private/Player/LMPlayerController.cpp new file mode 100644 index 0000000..ff9c0c7 --- /dev/null +++ b/Source/LegumeMix/Private/Player/LMPlayerController.cpp @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Player/LMPlayerController.h" +#include "EnhancedInputSubsystems.h" +#include "EnhancedInputComponent.h" + +void ALMPlayerController::BeginPlay() +{ + Super::BeginPlay(); + EnhancedInputSubsystem = GetLocalPlayer()->GetSubsystem(); + EnhancedInputSubsystem->AddMappingContext(DefaultMappingContext, 0); +} + +void ALMPlayerController::SetupInputComponent() +{ + Super::SetupInputComponent(); + UEnhancedInputComponent* Input = Cast(InputComponent); + Input->BindAction(MoveAction, ETriggerEvent::Triggered, this, &ALMPlayerController::Move); +} + +void ALMPlayerController::Move(const FInputActionValue& InputValue) +{ + const FVector2d VectorDirection = InputValue.Get(); + GetPawn()->AddMovementInput(GetPawn()->GetActorForwardVector(), VectorDirection.X); + GetPawn()->AddMovementInput(GetPawn()->GetActorRightVector(), VectorDirection.Y); +} diff --git a/Source/LegumeMix/Public/Player/LMPlayer.h b/Source/LegumeMix/Public/Player/LMPlayer.h new file mode 100644 index 0000000..effd765 --- /dev/null +++ b/Source/LegumeMix/Public/Player/LMPlayer.h @@ -0,0 +1,29 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Character.h" +#include "LMPlayer.generated.h" + +UCLASS() +class LEGUMEMIX_API ALMPlayer : public ACharacter +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + ALMPlayer(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + +}; diff --git a/Source/LegumeMix/Public/Player/LMPlayerController.h b/Source/LegumeMix/Public/Player/LMPlayerController.h new file mode 100644 index 0000000..1634728 --- /dev/null +++ b/Source/LegumeMix/Public/Player/LMPlayerController.h @@ -0,0 +1,41 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/PlayerController.h" +#include "EnhancedInputSubsystems.h" +#include "LMPlayerController.generated.h" + +/** + * + */ +UCLASS() +class LEGUMEMIX_API ALMPlayerController : public APlayerController +{ + GENERATED_BODY() + +public: + virtual void BeginPlay() override; + +private: + UPROPERTY() + UEnhancedInputLocalPlayerSubsystem* EnhancedInputSubsystem; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowprivateAccess = true)) + TObjectPtr DefaultMappingContext; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr MoveAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr LookAction; + + UPROPERTY(EditAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = true)) + TObjectPtr JumpAction; + + virtual void SetupInputComponent() override; + void Move(const FInputActionValue& InputValue); + + +};