From fb981ce2d6db60c4caf1984dd32f446d7eaa3c36 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Thu, 10 Nov 2022 11:52:10 +0000 Subject: [PATCH] Created Custom FP Character with custom Interact Created a Temp Character script and gave it functionallity, also gave it the custom keybind E so when pressed it displays a log message so I know it works. Also created a temporary gamemode for merchant level --- Config/DefaultEngine.ini | 2 +- Content/Blueprints/BP_MyTempCharacter.uasset | 3 ++ Content/Levels/MerchantPrototype.umap | 4 +- Content/Merchant/BP_MerchantGameMode.uasset | 3 ++ .../PlayerTemp/TempCharacter.cpp | 54 +++++++++++++++++++ .../PlayerTemp/TempCharacter.h | 33 ++++++++++++ 6 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 Content/Blueprints/BP_MyTempCharacter.uasset create mode 100644 Content/Merchant/BP_MerchantGameMode.uasset create mode 100644 Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp create mode 100644 Source/the_twilight_abyss/PlayerTemp/TempCharacter.h diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 197fc84..93b215a 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -28,6 +28,6 @@ bOffsetPlayerGamepadIds=False GameInstanceClass=/Script/Engine.GameInstance GameDefaultMap=/Game/Levels/Main.Main ServerDefaultMap=/Engine/Maps/Entry.Entry -GlobalDefaultGameMode=/Script/Engine.GameModeBase +GlobalDefaultGameMode=/Game/Merchant/BP_MerchantGameMode.BP_MerchantGameMode_C GlobalDefaultServerGameMode=None diff --git a/Content/Blueprints/BP_MyTempCharacter.uasset b/Content/Blueprints/BP_MyTempCharacter.uasset new file mode 100644 index 0000000..56f24b2 --- /dev/null +++ b/Content/Blueprints/BP_MyTempCharacter.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e80b44e582d11e6ad42033c0a1a16231f6301999bae071ebfb5b4e873f21d127 +size 22069 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index feb9ee1..2aae519 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:54f56812a38b4d3aaa9242a60febf557b7cbff2f830efc20ceff6571a6270971 -size 23663 +oid sha256:8754e6b425965184b0956fcfe7ebd1699d6733f6f44a1351ad6b9a44896afea0 +size 23754 diff --git a/Content/Merchant/BP_MerchantGameMode.uasset b/Content/Merchant/BP_MerchantGameMode.uasset new file mode 100644 index 0000000..191ec17 --- /dev/null +++ b/Content/Merchant/BP_MerchantGameMode.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a545be89d77a055ffcd3fcc1812d0c7bc90cfd0ff31e24e2d9cb4a33eb026df +size 19048 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp new file mode 100644 index 0000000..adbb10e --- /dev/null +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -0,0 +1,54 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "TempCharacter.h" + +#include "../../../Plugins/Developer/RiderLink/Source/RD/thirdparty/clsocket/src/ActiveSocket.h" + + +// Sets default values +ATempCharacter::ATempCharacter() +{ + // 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 ATempCharacter::BeginPlay() +{ + Super::BeginPlay(); + +} + +void ATempCharacter::ForwardInput(float Axis) +{ + AddMovementInput(GetActorForwardVector()* Axis); + +} + +void ATempCharacter::RightMoveInput(float Axis) +{ + AddMovementInput(GetActorRightVector()* Axis); +} + +// Called every frame +void ATempCharacter::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); +} + +// Called to bind functionality to input +void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + PlayerInputComponent->BindAxis(TEXT("Move Forward / Backward"), this, &ATempCharacter::ForwardInput); + PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput); + PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput); + PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput); + PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); +} + +void ATempCharacter::KeyPressed(FKey Interact) +{ + UE_LOG(LogTemp, Display, TEXT("Interact key is being pressed")); +} diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h new file mode 100644 index 0000000..0c0a54f --- /dev/null +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -0,0 +1,33 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Character.h" +#include "TempCharacter.generated.h" + +UCLASS() +class THE_TWILIGHT_ABYSS_API ATempCharacter : public ACharacter +{ + GENERATED_BODY() + +public: + // Sets default values for this character's properties + ATempCharacter(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + + void ForwardInput(float Axis); + void RightMoveInput(float Axis); + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + void KeyPressed(FKey Interact); + +};