diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 3472834..b7a47c7 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,8 +1,20 @@ [/Script/EngineSettings.GameMapsSettings] -GameDefaultMap=/Game/Worlds/MainMenu.MainMenu EditorStartupMap=/Game/Worlds/Playground1.Playground1 +LocalMapOptions= +TransitionMap=None +bUseSplitscreen=True +TwoPlayerSplitscreenLayout=Horizontal +ThreePlayerSplitscreenLayout=FavorTop +FourPlayerSplitscreenLayout=Grid +bShowAllPlayerWidgetsWhenSplitscreenDisabled=False +bOffsetPlayerGamepadIds=False +GameInstanceClass=/Script/Engine.GameInstance +GameDefaultMap=/Game/Worlds/MainMenu.MainMenu +ServerDefaultMap=/Engine/Maps/Entry.Entry +GlobalDefaultGameMode=/Script/Engine.GameModeBase +GlobalDefaultServerGameMode=None [/Script/Engine.RendererSettings] r.AllowStaticLighting=False diff --git a/Content/TEST/MyCharacter_BP.uasset b/Content/TEST/MyCharacter_BP.uasset new file mode 100644 index 0000000..ec406d2 Binary files /dev/null and b/Content/TEST/MyCharacter_BP.uasset differ diff --git a/Content/TEST/MyGameModeBase_BP.uasset b/Content/TEST/MyGameModeBase_BP.uasset new file mode 100644 index 0000000..6c1a541 Binary files /dev/null and b/Content/TEST/MyGameModeBase_BP.uasset differ diff --git a/Content/TEST/MyPlayerController_BP.uasset b/Content/TEST/MyPlayerController_BP.uasset new file mode 100644 index 0000000..be50265 Binary files /dev/null and b/Content/TEST/MyPlayerController_BP.uasset differ diff --git a/Content/UI_Menus/TEMP/IMC_Default.uasset b/Content/UI_Menus/TEMP/IMC_Default.uasset index 9730287..acd8b6d 100644 Binary files a/Content/UI_Menus/TEMP/IMC_Default.uasset and b/Content/UI_Menus/TEMP/IMC_Default.uasset differ diff --git a/Content/Worlds/Playground1.umap b/Content/Worlds/Playground1.umap index 007dbeb..60b0faa 100644 Binary files a/Content/Worlds/Playground1.umap and b/Content/Worlds/Playground1.umap differ diff --git a/OpenConflict.uproject b/OpenConflict.uproject index 48fb6e9..5c87fb6 100644 --- a/OpenConflict.uproject +++ b/OpenConflict.uproject @@ -7,7 +7,10 @@ { "Name": "OpenConflict", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ], "Plugins": [ diff --git a/Source/OpenConflict/Private/MyGameModeBase.cpp b/Source/OpenConflict/Private/MyGameModeBase.cpp new file mode 100644 index 0000000..c474641 --- /dev/null +++ b/Source/OpenConflict/Private/MyGameModeBase.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MyGameModeBase.h" + diff --git a/Source/OpenConflict/Private/MyPlayerCharacter/MyCharacter.cpp b/Source/OpenConflict/Private/MyPlayerCharacter/MyCharacter.cpp new file mode 100644 index 0000000..f467a78 --- /dev/null +++ b/Source/OpenConflict/Private/MyPlayerCharacter/MyCharacter.cpp @@ -0,0 +1,23 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MyPlayerCharacter/MyCharacter.h" + +// Sets default values +AMyCharacter::AMyCharacter() +{ + // 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; + + CameraComponent = CreateDefaultSubobject(TEXT("CameraComponent")); + CameraComponent->SetupAttachment(RootComponent); + CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, 50.0f)); + CameraComponent->bUsePawnControlRotation = true; +} + +// Called when the game starts or when spawned +void AMyCharacter::BeginPlay() +{ + Super::BeginPlay(); + +} diff --git a/Source/OpenConflict/Private/MyPlayerCharacter/MyPlayerController.cpp b/Source/OpenConflict/Private/MyPlayerCharacter/MyPlayerController.cpp new file mode 100644 index 0000000..3f228ee --- /dev/null +++ b/Source/OpenConflict/Private/MyPlayerCharacter/MyPlayerController.cpp @@ -0,0 +1,85 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "MyPlayerCharacter/MyPlayerController.h" +#include "EnhancedInputComponent.h" +#include "EnhancedInputSubsystems.h" +#include "Components/SplineMeshComponent.h" + +AMyPlayerController::AMyPlayerController() +{ +} + +void AMyPlayerController::BeginPlay() +{ + Super::BeginPlay(); + PlayerCharacter = Cast(GetCharacter()); + + if (AMyPlayerController* PC = Cast(this)) + { + if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem(PC->GetLocalPlayer())) + { + if(PlayerInputContext) + { + Subsystem->AddMappingContext(PlayerInputContext, 0); + } + } + } +} + +void AMyPlayerController::SetupInputComponent() +{ + Super::SetupInputComponent(); + if (AMyPlayerController* PC = Cast(this)) + { + if (UEnhancedInputComponent* Subsystem = Cast(InputComponent)) + { + if (MoveAction) + { + Subsystem->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AMyPlayerController::Move); + } + if (JumpAction) + { + Subsystem->BindAction(JumpAction, ETriggerEvent::Started, this, &AMyPlayerController::Jump); + } + if (LookAction) + { + Subsystem->BindAction(LookAction, ETriggerEvent::Triggered, this, &AMyPlayerController::Look); + } + } + } +} + +void AMyPlayerController::Move(const FInputActionValue& Value) +{ + FVector2D MovementVector = Value.Get(); + + if (APawn* ControlledPawn = GetPawn()) + { + FRotator CameraRotation = GetControlRotation(); + FRotator YawRotation(0.f, CameraRotation.Yaw, 0.f); + + FVector ForwardDiection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X); + FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y); + + ControlledPawn->AddMovementInput(ForwardDiection, MovementVector.Y); + ControlledPawn->AddMovementInput(RightDirection,MovementVector.X); + + } +} + +void AMyPlayerController::Look(const FInputActionValue& Value) +{ + FVector2D LookAxisVector = Value.Get(); + + if (APawn* ControlledPawn = GetPawn()) + { + AddYawInput(LookAxisVector.X); + AddPitchInput(LookAxisVector.Y); + } +} + +void AMyPlayerController::Jump(const FInputActionValue& Value) +{ +} + diff --git a/Source/OpenConflict/Public/MyGameModeBase.h b/Source/OpenConflict/Public/MyGameModeBase.h new file mode 100644 index 0000000..e522ec5 --- /dev/null +++ b/Source/OpenConflict/Public/MyGameModeBase.h @@ -0,0 +1,17 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/GameModeBase.h" +#include "MyGameModeBase.generated.h" + +/** + * + */ +UCLASS() +class OPENCONFLICT_API AMyGameModeBase : public AGameModeBase +{ + GENERATED_BODY() + +}; diff --git a/Source/OpenConflict/Public/MyPlayerCharacter/MyCharacter.h b/Source/OpenConflict/Public/MyPlayerCharacter/MyCharacter.h new file mode 100644 index 0000000..fef5a88 --- /dev/null +++ b/Source/OpenConflict/Public/MyPlayerCharacter/MyCharacter.h @@ -0,0 +1,28 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "Camera/CameraComponent.h" +#include "CoreMinimal.h" +#include "GameFramework/Character.h" +#include "MyCharacter.generated.h" + + +UCLASS() +class OPENCONFLICT_API AMyCharacter : public ACharacter +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + AMyCharacter(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera") + UCameraComponent* CameraComponent; + +}; diff --git a/Source/OpenConflict/Public/MyPlayerCharacter/MyPlayerController.h b/Source/OpenConflict/Public/MyPlayerCharacter/MyPlayerController.h new file mode 100644 index 0000000..b75b6b6 --- /dev/null +++ b/Source/OpenConflict/Public/MyPlayerCharacter/MyPlayerController.h @@ -0,0 +1,51 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "EnhancedInputComponent.h" +#include "EnhancedInputSubsystems.h" +#include "MyCharacter.h" +#include "CoreMinimal.h" +#include "GameFramework/PlayerController.h" +#include "MyPlayerController.generated.h" + + +/** + * + */ +UCLASS() +class OPENCONFLICT_API AMyPlayerController : public APlayerController +{ + GENERATED_BODY() +public: + AMyPlayerController(); + +protected: + virtual void BeginPlay() override; + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input") + UInputMappingContext* PlayerInputContext; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input") + UInputAction* MoveAction; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input") + UInputAction* LookAction; + + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Input") + UInputAction* JumpAction; + +public: + virtual void SetupInputComponent() override; + + UPROPERTY() + AMyCharacter* PlayerCharacter; + +private: + void Move(const FInputActionValue& Value); + void Look(const FInputActionValue& Value); + void Jump(const FInputActionValue& Value); + + + + +};