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 <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()
|
||||
|
|
|
@ -30,6 +30,11 @@ protected:
|
|||
UPROPERTY(EditDefaultsOnly)
|
||||
float MaxDamage = 150.f;
|
||||
|
||||
public:
|
||||
ADemolitionCharacter(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue