Files
UE5-Modular-Game-Framework/docs/blueprints/02-player/BPC_HealthSystem.asset.md
Lefteris Notas 3ca87a7893 Add asset creation sheets for various systems and UI components
- Created Save/Load & Death Loop asset sheet detailing checkpoint, death handling, and respawn systems.
- Added UI widget creation sheets for pause menu, settings menu, inventory, journal viewer, objective display, notification toast, screen effect controller, accessibility UI, diegetic HUD frame, menu flow controller, and credits screen.
- Implemented HUD controller and interaction prompt display assets with detailed wiring instructions.
- Established narrative systems asset sheet including components for narrative state, objectives, dialogue playback, and branching consequences.
- Developed weapons, AI, and adaptive systems asset creation sheet outlining weapon base, enemy AI components, and adaptive gameplay mechanics.
- Compiled meta, settings, and polish asset creation sheet covering progress tracking, achievement systems, accessibility settings, and various polish components.
- Defined input actions and mapping contexts for enhanced input system, including gameplay actions and context priorities.
- Created state management assets including enums, structs, data asset, and state manager component for action gating and state transitions.
2026-05-20 15:34:06 +03:00

99 lines
2.9 KiB
Markdown

# BPC_HealthSystem — Asset Implementation
> **UE5 Asset:** `/Game/Framework/Player/BPC_HealthSystem`
> **Parent Class:** `ActorComponent`
> **Attach To:** Player pawn + Enemy pawns
---
## Create This Asset
1. Content Browser → `Content/Framework/Player/`
2. Right-click → **Blueprint Class** → Parent: `ActorComponent`
3. Name: `BPC_HealthSystem`
---
## Variables to Add
| Variable | Type | Default | Category |
|----------|------|---------|----------|
| `MaxHealth` | `Float` | `100.0` | Config |
| `CurrentHealth` | `Float` | `100.0` | State |
| `bIsDead` | `Boolean` | `false` | State |
| `DamageResistance` | `Float` | `0.0` | Config |
| `bCanHeal` | `Boolean` | `true` | Config |
| `HealthRegenRate` | `Float` | `0.0` | Config |
| `HealthRegenDelay` | `Float` | `5.0` | Config |
| `LastDamageTime` | `Float` | `0.0` | State |
---
## What to Wire
### Override: BeginPlay
```
[Event BeginPlay]
├─ Set CurrentHealth = MaxHealth
└─ Enable Tick (if regen > 0)
```
### Function: ApplyDamage
```
Input: DamageAmount(Float), DamageCauser(AActor), DamageType(GameplayTag)
[BlueprintCallable]
├─ Branch: bIsDead? → True: Return 0
├─ Calculate: EffectiveDamage = DamageAmount * (1.0 - DamageResistance)
├─ Set CurrentHealth = FMax(CurrentHealth - EffectiveDamage, 0)
├─ Set LastDamageTime = GetGameTimeInSeconds
├─ Call OnHealthChanged(CurrentHealth, MaxHealth, -EffectiveDamage)
├─ Branch: CurrentHealth <= 0?
│ True → Set bIsDead = true → Call OnDeath(DamageCauser)
└─ Return EffectiveDamage
```
### Function: Heal
```
Input: HealAmount(Float)
[BlueprintCallable]
├─ Branch: bIsDead? → True: Return 0
├─ Branch: Not bCanHeal? → True: Return 0
├─ Calculate: ActualHeal = FMin(HealAmount, MaxHealth - CurrentHealth)
├─ Set CurrentHealth += ActualHeal
├─ Call OnHealthChanged(CurrentHealth, MaxHealth, ActualHeal)
└─ Return ActualHeal
```
### Override: Tick
```
[Event Tick]
├─ Branch: bIsDead OR HealthRegenRate <= 0 → Return
├─ Branch: (GameTime - LastDamageTime) < HealthRegenDelay → Return
├─ Heal(HealthRegenRate * DeltaSeconds)
```
### Event Dispatchers to Create
| Dispatcher | Parameters |
|------------|-----------|
| `OnHealthChanged` | `Current` (Float), `Max` (Float), `Delta` (Float) |
| `OnDeath` | `Killer` (AActor) |
| `OnHealed` | `Amount` (Float), `Healer` (AActor) |
| `OnDamageReceived` | `Amount` (Float), `Causer` (AActor), `Type` (GameplayTag) |
---
## Attach to Pawn
1. Open player pawn Blueprint
2. **Add Component → BPC_HealthSystem**
3. Optionally adjust `MaxHealth`, `DamageResistance` in Details panel
---
## Test It
- [ ] PIE: check BeginPlay → CurrentHealth = 100
- [ ] Call ApplyDamage(25) → health drops to 75 → OnHealthChanged fires
- [ ] Call Heal(10) → health rises to 85 → OnHealed fires
- [ ] Call ApplyDamage(100) → death → OnDeath fires → bIsDead = true