Unreal Engine 5.6 AI Tutorial #19 (Sep 2025) Behavior Tree NPC Chase, Attack & Return to Spawn
Автор: Amar Sen
Загружено: 2025-09-03
Просмотров: 167
🎮 Unreal Engine 5 AI Tutorial | Behavior Tree NPC Chase, Attack & Return to Spawn
In this episode, we build a complete AI Behavior System for an NPC enemy using Behavior Trees, Blackboards, and Gameplay Abilities in Unreal Engine 5. Step by step, I’ll show you how to make your NPC chase the player, attack, and then return to their original location once the player is defeated.
🔑 What We Covered in This Tutorial:
Setting up Behavior Tree & Blackboard
Created a Behavior Tree (BT_NPC) to control decision-making.
Created a Blackboard (BB_NPC) to store variables like Target Actor and Initial Location.
Explained how selectors, sequences, and decorators decide AI actions.
Connecting AI Controller to Behavior Tree
Used the AI Controller to run the Behavior Tree once it possesses the NPC.
Implemented logic to detect the player using the Perception System and assign them as the Target Actor.
NPC Chasing the Player
Added the Move To task so the NPC chases the player when detected.
Configured acceptable radius for smoother chasing.
Setup a NavMesh Bounds Volume to enable AI navigation.
Equipping & Unequipping Weapon (Gameplay Ability System)
Built a custom BT Task to activate Gameplay Abilities directly from the Behavior Tree.
NPC equips weapon when spotting the player.
NPC unequips weapon and waits when the target is lost.
NPC Attacking the Player
Triggered light attack ability when NPC reaches the player.
Added random wait times before attacks for more natural behavior.
Detecting Player Death & Stopping Attacks
Created a BT Task to check if Target Actor is dead.
Used Gameplay Tags (State.Dead) to identify death.
Cleared Target Actor so NPC stops attacking after the player dies.
Returning to Original Location
Stored NPC’s spawn location in the Blackboard as Initial Location.
After unequipping weapon, NPC returns to spawn point and resumes idle state.
✅ Final Behavior Achieved:
NPC patrols idle until the player is detected.
NPC equips weapon, chases the player, and attacks.
When the player dies, NPC unequips weapon and returns to spawn.
📌 Why This Matters:
Behavior Trees and Blackboards make AI decision-making modular, visual, and easy to debug compared to hardcoded logic. Combining this with the Gameplay Ability System (GAS) gives you powerful control over AI combat behaviors in action RPGs.
🔥 More Unreal Engine Tutorials Coming Soon!
Next, we’ll expand this system to include:
Blocking & parry mechanics ⚔️
Smarter combat decision-making 🧠
Advanced enemy states like retreating or group behavior 👥
#UnrealEngine5 #UE5AI #BehaviorTree #Blackboard #GameplayAbilitySystem #UnrealEngineTutorial #UE5Tutorial #UnrealEngineAI #NPCChase #NPCCombat #UE5RPG #UnrealEngine5Tutorial #AIperception #UE5GameDev #UnrealEngineRPG #GameDevelopment #UnrealEngineAICombat #UE5EnemyAI
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: