Files
UE5-Modular-Game-Framework/docs/blueprints/09-ai/80_BP_EnemyBase.md
Lefteris Notas 411edea8ce add blueprints
2026-05-19 13:22:27 +03:00

6.1 KiB
Raw Blame History

58 — BP_EnemyBase

Blueprint Spec — UE 5.55.7


Parent Class

Character

Dependencies

Purpose

Base enemy character blueprint. Provides movement, animation, damage reaction, ragdoll, and interaction with the AI controller system. Designed to be extended for specific enemy types (humanoid, creature, drone). All AI logic is in the controller; the pawn provides physical representation and animation state.

Variables

Name Type Description
AIProfile DA_AIProfile Enemy configuration asset
HealthComponent BPC_HealthComponent Health pool
StaminaComponent BPC_StaminaComponent Stamina for actions
PatrolPathRef BP_PatrolPath Assigned patrol route
SkeletalMesh USkeletalMeshComponent Visual mesh
AnimationBP UAnimInstance Animation blueprint instance
WeakSpotComponents Array Weak point references
bIsStaggered Bool Hit reaction state
bIsRagdoll Bool Death ragdoll state
RagdollLifetime Float Seconds before ragdoll cleanup
LootTable TArray Dropped items on death
AlertColor FLinearColor VFX color matching alert level
FootstepSounds TMap<UPhysicalMaterial, USoundBase> Surface-based footsteps
EnemyTypeTag FGameplayTag e.g. Tag.Enemy.Humanoid

Structs

Struct Fields Description
FLootEntry ItemTag: FGameplayTag, DropChance: Float, MinCount: Int, MaxCount: Int Loot definition
FWeakSpot BoneName: FName, DamageMultiplier: Float, bDestroyed: Bool, HitVFX: UParticleSystem Weak point data

Functions

Name Inputs Outputs Description
InitializeEnemy Profile: DA_AIProfile Set stats, components, attachment
OnTakeDamage DamageResult: FDamageResult React to damage (stagger, VFX)
OnDeath Play death anim or ragdoll
StartRagdoll HitLocation: FVector, Impulse: FVector Physics death
EndRagdoll Cleanup and destroy
SpawnLoot Drop items at death location
GetWeakSpotMultiplier BoneName: FName Float Return damage multiplier
SetEnemyState NewState: EAIState Update animation state
PlayFootstep Surface: UPhysicalMaterial Footstep sound
GetEyeLocation FVector Perception reference point
CanBeStaggered Bool Stagger immunity check
PlayStaggerAnimation Hit reaction montage
OnStaggerEnd Return to normal state
SetVisibilityBasedAnimTickOption Option: EVisibilityBasedAnimTickOption Performance culling

Enums

Enum Values Description
EEnemyArchetype Humanoid, Creature, Drone, Turret, Boss Enemy structural type
EHitReactionType None, Flinch, Stagger, Knockback, Launch Reaction severity

Blueprint Flow

[OnTakeDamage]
  └─► ApplyDamage to HealthComponent
  └─► If HealthComponent.Health <= 0 → OnDeath
  └─► Else:
         HitReaction = DetermineReaction(DamageResult)
         If HitReaction >= Stagger && CanBeStaggered:
             bIsStaggered = true
             PlayStaggerAnimation(DamageResult.HitDirection)
         SpawnHitVFX(DamageResult.HitLocation)
         Notify AIController of damage via dispatcher

[OnDeath]
  └─► Set AIState = Disabled on controller
  └─► Stop all AI logic
  └─► If AIProfile.bUseRagdoll:
         StartRagdoll(DamageResult.HitLocation, DamageResult.Impulse)
         SetLifeSpan(RagdollLifetime)
  └─► Else:
         PlayDeathAnimation()
         SetLifeSpan(DeathAnimTime)
  └─► SpawnLoot()
  └─► Broadcast OnEnemyKilled
  └─► Unregister from AlertSystem

[SpawnLoot]
  └─► For each FLootEntry:
         If Random < DropChance:
             Count = RandomRange(MinCount, MaxCount)
             Spawn pickup actor with ItemTag and Count

Animation State Mapping

EAIState Animation State Notes
Idle Idle Standing, breathing
Patrol Walk Speed from profile
Suspicious Walk (slower) Looking around
Alerted Walk (fast) Ready stance
Combat Run / Jog Sprint toward target
Searching Walk (scanning) Head-turning
Fleeing Sprint Panic movement
Disabled Stagger / Stun Hit reaction or downed

Communications With

Target Method Why
BPC_AIControllerBase Possessing controller AI state and behavior
BPC_HealthComponent Get Component Health modify and death
BPC_DamageHandlerComponent Get Component Process incoming damage
BPC_CombatFeedbackComponent Get Component Blood, hit FX
Animation Blueprint Direct State machine query
BP_PatrolPath Direct Waypoint navigation
World Spawning System Direct Loot spawning

Reuse Notes

  • Subclass for different enemy visuals, hitbox setups, and animation sets
  • Weak spots defined per blueprint (head, back weak point, glowing core)
  • Loot table data-driven: design new enemies by swapping DA_AIProfile
  • Ragdoll vs death animation toggle per enemy type
  • AnimBP queries AIState for state-driven animation