Replace default CharacterMovementComponent with NakatomiCMC

This commit is contained in:
baz 2024-01-04 15:50:15 +00:00
parent 56aa855a7c
commit 01aeecf953
6 changed files with 21 additions and 6 deletions

View File

@ -5,7 +5,7 @@
#define COLLISION_WEAPON ECC_GameTraceChannel1
AEnemyCharacter::AEnemyCharacter()
AEnemyCharacter::AEnemyCharacter(const FObjectInitializer& ObjectInitializer) : ANakatomiCharacter(ObjectInitializer)
{
RandomWeaponParameters = CreateDefaultSubobject<URandomWeaponParameters>(TEXT("Random Weapon Parameters"));

View File

@ -27,7 +27,7 @@ private:
FTimerHandle CooldownTimerHandle;
public:
AEnemyCharacter();
AEnemyCharacter(const FObjectInitializer& ObjectInitializer);
UBehaviorTree* GetBehaviourTree();

View File

@ -3,12 +3,17 @@
#include "NakatomiCharacter.h"
#include "NakatomiCMC.h"
// Sets default values
ANakatomiCharacter::ANakatomiCharacter()
ANakatomiCharacter::ANakatomiCharacter(const FObjectInitializer& ObjectInitializer) : Super(
ObjectInitializer.SetDefaultSubobjectClass<UNakatomiCMC>(ACharacter::CharacterMovementComponentName))
{
// 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;
NakatomiCMC = Cast<UNakatomiCMC>(GetCharacterMovement());
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
HealthComponent->OnDamaged.BindUFunction(this, "OnDamaged");
HealthComponent->OnDeath.BindUFunction(this, "OnDeath");

View File

@ -5,6 +5,7 @@
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "HealthComponent.h"
#include "NakatomiCMC.h"
#include "Throwable.h"
#include "Weapon.h"
#include "NakatomiCharacter.generated.h"
@ -38,6 +39,10 @@ public:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
TArray<TSubclassOf<AThrowable>> ThrowableInventory;
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true"))
UNakatomiCMC* NakatomiCMC;
private:
UPROPERTY(VisibleDefaultsOnly)
UHealthComponent* HealthComponent = nullptr;
@ -47,9 +52,10 @@ private:
UPROPERTY(EditDefaultsOnly)
int MaximumThrowableInventorySize = 4;
public:
// Sets default values for this character's properties
ANakatomiCharacter();
ANakatomiCharacter(const FObjectInitializer& ObjectInitializer);
protected:
// Called when the game starts or when spawned

View File

@ -19,7 +19,7 @@
#define COLLISION_WEAPON ECC_GameTraceChannel1
// Sets default values
APlayerCharacter::APlayerCharacter()
APlayerCharacter::APlayerCharacter(const FObjectInitializer& ObjectInitializer) : ANakatomiCharacter(ObjectInitializer)
{
// 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;

View File

@ -14,6 +14,7 @@
#include "Blueprint/UserWidget.h"
#include "Perception/AIPerceptionStimuliSourceComponent.h"
#include "InteractableComponent.h"
#include "NakatomiCMC.h"
#include "Throwable.h"
#include "PlayerCharacter.generated.h"
@ -95,6 +96,9 @@ protected:
float DefaultAimSensitivity = 45.0f;
private:
// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (AllowPrivateAccess = "true"))
// UNakatomiCMC* NakatomiCMC;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true"))
USpringArmComponent* CameraSpringArmComponent = nullptr;
@ -132,7 +136,7 @@ private:
public:
// Sets default values for this character's properties
APlayerCharacter();
APlayerCharacter(const FObjectInitializer& ObjectInitializer);
protected:
// Called when the game starts or when spawned