[UE4]FPS Project-9 (Attack)

윤정민·2022년 7월 20일
0

Unreal Engine

목록 보기
14/34

1.Character Damage

  • 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();
    		}

2. Enemy OnHit

  • Enemy.cpp : Character의 DealDamage 함수 실행
    AMonsterShooterCharacter* Char = Cast<AMonsterShooterCharacter>(OtherActor);

	if (Char)
	{
		Char->DealDamage(DamageValue);
	}

3. 발사체 OnHit

  • Enemy의 DealDamage 함수 실행
  	AEnemy* Enemy = Cast<AEnemy>(OtherActor);
	if (Enemy)
	{
		Enemy->DealDamage(DamageValue);
		Destroy();
	}
profile
그냥 하자

0개의 댓글