diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index d980f23..1b1c8ac 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,7 +1,9 @@ [/Script/EngineSettings.GameMapsSettings] -GameDefaultMap=/Engine/Maps/Templates/OpenWorld +GameDefaultMap=/Game/CTP/01_Level/L_Default.L_Default +GlobalDefaultGameMode=/Script/M4_CPP.M4_Gamemode +EditorStartupMap=/Game/CTP/01_Level/L_Default.L_Default [/Script/Engine.RendererSettings] r.AllowStaticLighting=False diff --git a/Content/CTP/01_Level/L_Default.umap b/Content/CTP/01_Level/L_Default.umap new file mode 100644 index 0000000..e564e01 Binary files /dev/null and b/Content/CTP/01_Level/L_Default.umap differ diff --git a/Content/CTP/03_Input/IA_Move.uasset b/Content/CTP/03_Input/IA_Move.uasset new file mode 100644 index 0000000..418a3d8 Binary files /dev/null and b/Content/CTP/03_Input/IA_Move.uasset differ diff --git a/Content/CTP/03_Input/IMC_Default.uasset b/Content/CTP/03_Input/IMC_Default.uasset new file mode 100644 index 0000000..d2638f4 Binary files /dev/null and b/Content/CTP/03_Input/IMC_Default.uasset differ diff --git a/Content/CTP/L_Default.umap b/Content/CTP/L_Default.umap index ae213e2..09ff304 100644 Binary files a/Content/CTP/L_Default.umap and b/Content/CTP/L_Default.umap differ diff --git a/Source/M4_CPP/private/M4_Gamemode.cpp b/Source/M4_CPP/private/M4_Gamemode.cpp index b16f27c..ebfccda 100644 --- a/Source/M4_CPP/private/M4_Gamemode.cpp +++ b/Source/M4_CPP/private/M4_Gamemode.cpp @@ -1,11 +1,17 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "M4_Gamemode.h" +#include "M4_PlayerController.h" +#include "M4_PlayerPawn.h" + AM4_Gamemode::AM4_Gamemode() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = false; + PlayerControllerClass = AM4_PlayerController::StaticClass(); + DefaultPawnClass = AM4_PlayerPawn::StaticClass(); + } void AM4_Gamemode::BeginPlay() diff --git a/Source/M4_CPP/private/M4_PlayerController.cpp b/Source/M4_CPP/private/M4_PlayerController.cpp index 2f53180..3574487 100644 --- a/Source/M4_CPP/private/M4_PlayerController.cpp +++ b/Source/M4_CPP/private/M4_PlayerController.cpp @@ -3,16 +3,33 @@ #include "M4_PlayerController.h" +#include "Camera/CameraComponent.h" + AM4_PlayerController::AM4_PlayerController() { + CameraComponent = CreateDefaultSubobject(TEXT("CameraComponent")); + CameraComponent->ProjectionMode = ECameraProjectionMode::Orthographic; + CameraComponent->OrthoWidth = 2048.0f; + CameraComponent->SetupAttachment(RootComponent); } void AM4_PlayerController::BeginPlay() { Super::BeginPlay(); + + if (CameraComponent) + { + CameraComponent->SetRelativeLocation(FVector(0, 0, 1000)); + CameraComponent->SetRelativeRotation(FRotator(-90.0f, 0.0f, 0.0f)); + } } void AM4_PlayerController::SetupInputComponent() { Super::SetupInputComponent(); +} + +void AM4_PlayerController::OnPossess(APawn* InPawn) +{ + Super::OnPossess(InPawn); } \ No newline at end of file diff --git a/Source/M4_CPP/private/M4_PlayerPawn.cpp b/Source/M4_CPP/private/M4_PlayerPawn.cpp index 697bd76..a612cfc 100644 --- a/Source/M4_CPP/private/M4_PlayerPawn.cpp +++ b/Source/M4_CPP/private/M4_PlayerPawn.cpp @@ -41,4 +41,19 @@ void AM4_PlayerPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AM4_PlayerPawn::Move); } } +} + +void AM4_PlayerPawn::Move(const FInputActionValue& Value) +{ + // Récupérer la valeur du mouvement (vecteur 2D pour horizontal/vertical) + FVector2D MovementVector = Value.Get(); + + // Appliquer le mouvement + if (Controller) + { + FVector NewLocation = GetActorLocation(); + NewLocation.X += MovementVector.X; + NewLocation.Y += MovementVector.Y; + SetActorLocation(NewLocation); + } } \ No newline at end of file diff --git a/Source/M4_CPP/public/M4_PlayerController.h b/Source/M4_CPP/public/M4_PlayerController.h index 26c6590..134320f 100644 --- a/Source/M4_CPP/public/M4_PlayerController.h +++ b/Source/M4_CPP/public/M4_PlayerController.h @@ -4,6 +4,7 @@ #include "CoreMinimal.h" #include "GameFramework/PlayerController.h" +#include "Camera/CameraComponent.h" #include "M4_PlayerController.generated.h" /** @@ -21,8 +22,10 @@ public: protected: virtual void SetupInputComponent() override; - virtual void OnPossess(); + virtual void OnPossess(APawn* InPawn) override; private: + UPROPERTY(VisibleAnywhere,BlueprintReadOnly ,Category="Centipede", meta = (AllowPrivateAccess = "true")) + TObjectPtr CameraComponent; }; diff --git a/Source/M4_CPP/public/M4_PlayerPawn.h b/Source/M4_CPP/public/M4_PlayerPawn.h index 481a906..58e4c70 100644 --- a/Source/M4_CPP/public/M4_PlayerPawn.h +++ b/Source/M4_CPP/public/M4_PlayerPawn.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "GameFramework/Pawn.h" #include "InputAction.h" +#include "InputActionValue.h" #include "Components/StaticMeshComponent.h" #include "EnhancedInputComponent.h" #include "EnhancedInputSubsystems.h" @@ -38,6 +39,8 @@ private: UPROPERTY(Category = "Centipede", VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) TObjectPtr MeshComponent; + void Move(const FInputActionValue& Value); + };