diff --git a/Source/Nakatomi/NakatomiCharacter.cpp b/Source/Nakatomi/NakatomiCharacter.cpp index aa2cb69..bd32960 100644 --- a/Source/Nakatomi/NakatomiCharacter.cpp +++ b/Source/Nakatomi/NakatomiCharacter.cpp @@ -10,6 +10,8 @@ ANakatomiCharacter::ANakatomiCharacter() PrimaryActorTick.bCanEverTick = true; HealthComponent = CreateDefaultSubobject(TEXT("Health Component")); + HealthComponent->OnDamaged.BindUFunction(this, "OnDamaged"); + HealthComponent->OnDeath.BindUFunction(this, "OnDeath"); } // Called when the game starts or when spawned @@ -218,3 +220,11 @@ void ANakatomiCharacter::CalculateHits(TArray* hits) void ANakatomiCharacter::ProcessHits(TArray hits) { } + +void ANakatomiCharacter::OnDamaged() +{ +} + +void ANakatomiCharacter::OnDeath() +{ +} diff --git a/Source/Nakatomi/NakatomiCharacter.h b/Source/Nakatomi/NakatomiCharacter.h index 6e1fd35..ddc78e1 100644 --- a/Source/Nakatomi/NakatomiCharacter.h +++ b/Source/Nakatomi/NakatomiCharacter.h @@ -83,4 +83,10 @@ protected: virtual void CalculateHits(TArray* hits); virtual void ProcessHits(TArray hits); + + UFUNCTION() + virtual void OnDamaged(); + + UFUNCTION() + virtual void OnDeath(); }; diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 4f1b45a..d31372c 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -8,7 +8,6 @@ #include "EnhancedInputSubsystems.h" #include "GameFramework/CharacterMovementComponent.h" #include "InputMappingContext.h" -#include "Destructable.h" #include "EnemyCharacter.h" #define COLLISION_WEAPON ECC_GameTraceChannel1 @@ -300,6 +299,17 @@ void APlayerCharacter::ProcessHits(TArray hits) } } +void APlayerCharacter::OnDamaged() +{ + Super::OnDamaged(); +} + +void APlayerCharacter::OnDeath() +{ + Super::OnDeath(); + UE_LOG(LogTemp, Error, TEXT("YOU ARE DEAD!")); +} + void APlayerCharacter::WeaponSwitchingCallback(const FInputActionInstance& Instance) { float value = Instance.GetValue().Get(); diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index 886bf95..665dea2 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -131,4 +131,8 @@ protected: virtual void CalculateHits(TArray* hits) override; virtual void ProcessHits(TArray hits) override; + + virtual void OnDamaged() override; + + virtual void OnDeath() override; };