Compare commits

...

2 Commits

Author SHA1 Message Date
baz c6059578ac Add basic PlayerCharacter 2024-06-12 00:34:24 +01:00
baz 90a0a4c515 Update Project settings 2024-06-12 00:34:11 +01:00
22 changed files with 342 additions and 0 deletions

View File

@ -2,6 +2,8 @@
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Engine/Maps/Templates/OpenWorld
GlobalDefaultGameMode=/Game/Gamemode/BP_DefaultGamemode.BP_DefaultGamemode_C
GameInstanceClass=/Script/vampires.VampireGameInstance
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12

BIN
Content/Gamemode/BP_DefaultGamemode.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Input/IA_Movement.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Input/IMC_Player.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Player/BP_PlayerCharacter.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Content/Player/BP_PlayerController.uasset (Stored with Git LFS) Normal file

Binary file not shown.

15
Source/vampires.Target.cs Normal file
View File

@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class vampiresTarget : TargetRules
{
public vampiresTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.AddRange( new string[] { "vampires" } );
}
}

View File

@ -0,0 +1,69 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlayerCharacter.h"
#include "VampirePlayerController.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h"
APlayerCharacter::APlayerCharacter()
{
// Create Camera Boom
CameraSpringArmComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraSpringArmComponent"));
CameraSpringArmComponent->SetupAttachment(RootComponent);
CameraSpringArmComponent->bDoCollisionTest = true;
CameraSpringArmComponent->bUsePawnControlRotation = false;
CameraSpringArmComponent->TargetArmLength = 1000;
CameraSpringArmComponent->bEnableCameraLag = false;
CameraSpringArmComponent->SocketOffset = { 0.0f, 0.0f, 0.0f };
CameraSpringArmComponent->SetRelativeRotation({-90.0, 0.0f, 0.0f});
// Create Camera
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera Component"));
CameraComponent->SetupAttachment(CameraSpringArmComponent, USpringArmComponent::SocketName);
CameraComponent->bUsePawnControlRotation = false;
CameraComponent->SetProjectionMode(ECameraProjectionMode::Type::Orthographic);
CameraComponent->SetOrthoWidth(4000.0f);
}
void APlayerCharacter::BeginPlay()
{
Super::BeginPlay();
}
void APlayerCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (AVampirePlayerController* TankPlayerController = Cast<AVampirePlayerController>(GetController()))
{
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(TankPlayerController->GetLocalPlayer()))
{
if (!InputMappingContext.IsNull())
{
InputSystem->AddMappingContext(InputMappingContext.LoadSynchronous(), 0);
}
}
}
if (UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
if (MovementAction)
{
Input->BindAction(MovementAction, ETriggerEvent::Triggered, this, &APlayerCharacter::MovementCallback);
}
}
}
void APlayerCharacter::MovementCallback(const FInputActionInstance& Instance)
{
FVector2D vec2 = Instance.GetValue().Get<FVector2D>();
if (vec2.Size() != 0.0f)
{
AddMovementInput({0.0f,1.0f,0.0f}, vec2.Y);
AddMovementInput({1.0f,0.0f,0.0f}, vec2.X);
}
}

View File

@ -0,0 +1,52 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "VampireCharacter.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "PlayerCharacter.generated.h"
class UInputMappingContext;
class UInputAction;
/**
*
*/
UCLASS()
class VAMPIRES_API APlayerCharacter : public AVampireCharacter
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
USpringArmComponent* CameraSpringArmComponent = nullptr;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UCameraComponent* CameraComponent = nullptr;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TSoftObjectPtr<UInputMappingContext> InputMappingContext;
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
UInputAction* MovementAction;
public:
APlayerCharacter();
protected:
virtual void BeginPlay() override;
public:
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
private:
UFUNCTION()
void MovementCallback(const FInputActionInstance& Instance);
};

View File

@ -0,0 +1,34 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VampireCharacter.h"
// Sets default values
AVampireCharacter::AVampireCharacter()
{
// 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 AVampireCharacter::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AVampireCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Called to bind functionality to input
void AVampireCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
}

View File

@ -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 "VampireCharacter.generated.h"
UCLASS()
class VAMPIRES_API AVampireCharacter : public ACharacter
{
GENERATED_BODY()
public:
// Sets default values for this character's properties
AVampireCharacter();
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;
};

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VampireGameInstance.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "VampireGameInstance.generated.h"
/**
*
*/
UCLASS()
class VAMPIRES_API UVampireGameInstance : public UGameInstance
{
GENERATED_BODY()
};

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VampireGameMode.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameMode.h"
#include "VampireGameMode.generated.h"
/**
*
*/
UCLASS()
class VAMPIRES_API AVampireGameMode : public AGameMode
{
GENERATED_BODY()
};

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VampirePlayerController.h"

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "VampirePlayerController.generated.h"
/**
*
*/
UCLASS()
class VAMPIRES_API AVampirePlayerController : public APlayerController
{
GENERATED_BODY()
};

View File

@ -0,0 +1,23 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class vampires : ModuleRules
{
public vampires(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "vampires.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, vampires, "vampires" );

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,15 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class vampiresEditorTarget : TargetRules
{
public vampiresEditorTarget(TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V5;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
ExtraModuleNames.AddRange( new string[] { "vampires" } );
}
}

View File

@ -3,6 +3,16 @@
"EngineAssociation": "5.4",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "vampires",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
],
"Plugins": [
{
"Name": "ModelingToolsEditorMode",