UE4 - Creating a RPG #21 - Melee Weapon Damage

노기현·2024년 11월 27일

Today's Lesson: Melee Weapon Damage

Summary

1. We show you how can make the AI lose health when you hit it with your sword.

2. We do this with a collision based system, firing off from an overlap event generated when your sword hits your enemy

Virtus Learning Hub


✅ Weapon_Sword 충돌 체크

◼️ Collision 생성
In Actor Blueprint <Weapon_Sword>

  • Skeletal Mesh - Collision
    - Collision Presets: OverlapAllDynamic
  • Add Component: Box Collision
    - Transform 조정
    - Collision - Collision Presets: OverlapAllDynamic

✅ Simple_AI 충돌 체크

  • Capsule Component - 이벤트 추가: On Component Begin Overlap

In Actor Blueprint <SwordCharacter>

  • Overlap된 Actor가 Weapon_Sword이면
    → Sword Character의 SlashSword 변수를 체크
    → True인 경우 진행
  • Simple AI의 Health를 감소시키고
    → 감소된 Health가 0 이하인지 체크
    → True인 경우 Death 함수 실행

✅ Result

  • Weapon_Sword 와 Simple_AI 충돌 후 데미지 처리
    //공격 한 번에 두 번 이상의 데미지가 처리되는 문제 발생
    AnimNotify 등으로 피격 판정을 체크하는 것이 좋아 보임
profile
RPG 기획자 지망생

0개의 댓글