Bind OnDeath and OnDamaged in BeginPlay on character
This commit is contained in:
parent
a2186205cc
commit
0d463d1ba2
Binary file not shown.
BIN
Content/Enemy/DemolitionWorker/C_DemolitionWorker.uasset (Stored with Git LFS)
BIN
Content/Enemy/DemolitionWorker/C_DemolitionWorker.uasset (Stored with Git LFS)
Binary file not shown.
|
@ -4,11 +4,20 @@
|
||||||
#include "DemolitionCharacter.h"
|
#include "DemolitionCharacter.h"
|
||||||
#include <Kismet/GameplayStatics.h>
|
#include <Kismet/GameplayStatics.h>
|
||||||
|
|
||||||
|
#include "EnemyAIController.h"
|
||||||
|
|
||||||
|
ADemolitionCharacter::ADemolitionCharacter(const FObjectInitializer& ObjectInitializer) : AEnemyCharacter(ObjectInitializer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void ADemolitionCharacter::BeginPlay()
|
void ADemolitionCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
GetHealthComponent()->OnDeath.BindUFunction(this, "Explode");
|
GetHealthComponent()->OnDeath.BindUFunction(this, "Explode");
|
||||||
|
auto controller = Cast<AEnemyAIController>(GetController());
|
||||||
|
GetHealthComponent()->OnDeath.BindUFunction(controller, "OnDeath");
|
||||||
|
GetHealthComponent()->OnDamaged.BindUFunction(controller, "OnDamaged");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ADemolitionCharacter::Explode()
|
void ADemolitionCharacter::Explode()
|
||||||
|
|
|
@ -30,6 +30,11 @@ protected:
|
||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
float MaxDamage = 150.f;
|
float MaxDamage = 150.f;
|
||||||
|
|
||||||
|
public:
|
||||||
|
ADemolitionCharacter(const FObjectInitializer& ObjectInitializer);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue