Move HealthComponent to base Character class

This commit is contained in:
baz 2024-06-12 21:35:12 +01:00
parent 8bf01234a0
commit e06b1738c2
4 changed files with 8 additions and 6 deletions

View File

@ -27,9 +27,6 @@ APlayerCharacter::APlayerCharacter()
CameraComponent->SetProjectionMode(ECameraProjectionMode::Type::Orthographic); CameraComponent->SetProjectionMode(ECameraProjectionMode::Type::Orthographic);
CameraComponent->SetOrthoWidth(4000.0f); CameraComponent->SetOrthoWidth(4000.0f);
// Create Health Component
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
// Create EXP Component // Create EXP Component
EXPComponent = CreateDefaultSubobject<UEXPComponent>(TEXT("EXP Component")); EXPComponent = CreateDefaultSubobject<UEXPComponent>(TEXT("EXP Component"));
} }

View File

@ -4,7 +4,6 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "EXPComponent.h" #include "EXPComponent.h"
#include "HealthComponent.h"
#include "VampireCharacter.h" #include "VampireCharacter.h"
#include "Camera/CameraComponent.h" #include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h" #include "GameFramework/SpringArmComponent.h"
@ -35,8 +34,6 @@ public:
UInputAction* MovementAction; UInputAction* MovementAction;
protected: protected:
UPROPERTY()
UHealthComponent* HealthComponent;
UPROPERTY() UPROPERTY()
UEXPComponent* EXPComponent; UEXPComponent* EXPComponent;

View File

@ -9,6 +9,8 @@ AVampireCharacter::AVampireCharacter()
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it. // 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; PrimaryActorTick.bCanEverTick = true;
// Create Health Component
HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("Health Component"));
} }
// Called when the game starts or when spawned // Called when the game starts or when spawned

View File

@ -4,6 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "GameFramework/Character.h" #include "GameFramework/Character.h"
#include "HealthComponent.h"
#include "VampireCharacter.generated.h" #include "VampireCharacter.generated.h"
UCLASS() UCLASS()
@ -11,6 +12,11 @@ class VAMPIRES_API AVampireCharacter : public ACharacter
{ {
GENERATED_BODY() GENERATED_BODY()
protected:
UPROPERTY()
UHealthComponent* HealthComponent;
public: public:
// Sets default values for this character's properties // Sets default values for this character's properties
AVampireCharacter(); AVampireCharacter();