MonsterShooterCharacter.h : 기본 Pawn
void DealDamage(float DamageAmount);
MonsterShooterCharacter.cpp : DealDamage
Health -= DamageAmount;
if (Health <= 0.0f)
{
//restart game
AMonsterShooterGameMode* MyGameMode =
Cast<AMonsterShooterGameMode>(UGameplayStatics::GetGameMode(GetWorld()));
if (MyGameMode)
{
MyGameMode->RestartGameplay(false);
}
Destroy();
}
AMonsterShooterCharacter* Char = Cast<AMonsterShooterCharacter>(OtherActor);
if (Char)
{
Char->DealDamage(DamageValue);
}
AEnemy* Enemy = Cast<AEnemy>(OtherActor);
if (Enemy)
{
Enemy->DealDamage(DamageValue);
Destroy();
}