Bind OnDeath and OnDamaged in BeginPlay on character

This commit is contained in:
baz 2024-03-04 19:25:53 +00:00
parent a2186205cc
commit 0d463d1ba2
4 changed files with 19 additions and 2 deletions

BIN
Content/Enemy/DemolitionWorker/AIC_DemolitionWorker.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

View File

@ -4,11 +4,20 @@
#include "DemolitionCharacter.h"
#include <Kismet/GameplayStatics.h>
#include "EnemyAIController.h"
ADemolitionCharacter::ADemolitionCharacter(const FObjectInitializer& ObjectInitializer) : AEnemyCharacter(ObjectInitializer)
{
}
void ADemolitionCharacter::BeginPlay()
{
Super::BeginPlay();
GetHealthComponent()->OnDeath.BindUFunction(this, "Explode");
auto controller = Cast<AEnemyAIController>(GetController());
GetHealthComponent()->OnDeath.BindUFunction(controller, "OnDeath");
GetHealthComponent()->OnDamaged.BindUFunction(controller, "OnDamaged");
}
void ADemolitionCharacter::Explode()

View File

@ -30,6 +30,11 @@ protected:
UPROPERTY(EditDefaultsOnly)
float MaxDamage = 150.f;
public:
ADemolitionCharacter(const FObjectInitializer& ObjectInitializer);
protected:
virtual void BeginPlay() override;
public: