Add Health Damage Delegates in Characters
This commit is contained in:
parent
6ad454a881
commit
7571a7fe7a
|
@ -10,6 +10,8 @@ ANakatomiCharacter::ANakatomiCharacter()
|
|||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
HealthComponent = CreateDefaultSubobject<UHealthComponent>(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<FHitResult>* hits)
|
|||
void ANakatomiCharacter::ProcessHits(TArray<FHitResult> hits)
|
||||
{
|
||||
}
|
||||
|
||||
void ANakatomiCharacter::OnDamaged()
|
||||
{
|
||||
}
|
||||
|
||||
void ANakatomiCharacter::OnDeath()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -83,4 +83,10 @@ protected:
|
|||
virtual void CalculateHits(TArray<FHitResult>* hits);
|
||||
|
||||
virtual void ProcessHits(TArray<FHitResult> hits);
|
||||
|
||||
UFUNCTION()
|
||||
virtual void OnDamaged();
|
||||
|
||||
UFUNCTION()
|
||||
virtual void OnDeath();
|
||||
};
|
||||
|
|
|
@ -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<FHitResult> 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<float>();
|
||||
|
|
|
@ -131,4 +131,8 @@ protected:
|
|||
virtual void CalculateHits(TArray<FHitResult>* hits) override;
|
||||
|
||||
virtual void ProcessHits(TArray<FHitResult> hits) override;
|
||||
|
||||
virtual void OnDamaged() override;
|
||||
|
||||
virtual void OnDeath() override;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue