Learn how you can implement Enemy AI with a Finite State Machine. This is a full implementation using Unity Hierarchical State Machine (Unity HFSM), a code-driven state machine framework for Unity.
👨💻 As always, all code from this video is available on GitHub: https://github.com/llamacademy/ai-ser...
👨💻 If you're just looking for Unity HFSM, it's here: https://github.com/Inspiaaa/UnityHFSM
🏷️Save 25% on the ultimate C# IDE: JetBrains Rider with code LLAMACADEMY: https://www.jetbrains.com/store/?sect...
📚 Resources:
⚫ Unity HFSM: https://github.com/Inspiaaa/UnityHFSM
⚫ This super cool Llama: https://assetstore.unity.com/packages...
⚫ Unity Particle Pack (free): https://assetstore.unity.com/packages...
⚫ AI Series 44 (Movement Prediction): • Better Enemy Chasing with Intercept C...
⚫ Damage System: • Damage Enemies and Objects with Guns ...
⚫ Unity 2021 Object Pooling API: • Unity 2021 Object Pool API - What is ...
⚫ Comparison of AI Behavior Frameworks: • Which AI Behavior Framework Should Yo...
🧡 Believe in LlamAcademy's mission and have received value from the videos? Here's how you can show your support:
🌟 Patreon: / llamacademy
🌟 YouTube Member: / @llamacademy or click the Join button on any video
📚 Take my Unity ShaderGraph Course:
https://www.gamedev.tv/p/unity-shader...
👕 Get yourself some LlamAcademy merch: https://llamacademy.myspreadshop.com/
💸 Use my Affiliate Link for Humble Bundles https://humblebundleinc.sjv.io/9g4ak4
💸 Publisher Sale! 50% OFF an entire publisher's Assets! Publisher changes weekly! https://assetstore.unity.com/publishe... (affiliate)
💸 Save up to 50% on NEW Assets: https://assetstore.unity.com/?new_sal... (affiliate)
Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
Chapters:
00:00 Topic Introduction
00:35 Unity HFSM Installation
01:25 What to Expect & High Level Design
02:50 FSM Design in Animator
06:22 Unity HFSM Key Classes - StateBase.cs, State.cs, StateMachine.cs
07:26 EnemyStateBase.cs Introduction
07:48 EnemyState.cs - Defines all possible states
08:00 StateEvent.cs - Defines all possible events
08:10 Enemy.cs - Set up State Machine with all states
09:58 EnemyStateBase.cs - Base State for all Enemy State Behaviors
11:45 IdleState.cs
12:18 ChaseState.cs
13:31 SpitState.cs & Spit.cs
14:45 AttackState.cs
15:22 BounceState.cs
15:34 RollState.cs
16:15 Add References & Update State Constructors - Enemy.cs
17:49 Detect Player Within Different Ranges - PlayerSensor.cs
18:18 Use Player Sensors - Enemy.cs
19:10 Add Chase/Idle Transitions - Enemy.cs
20:35 Add Roll Transitions - Enemy.cs
21:54 Detect Collisions while Rolling - RollImpactSensor.cs
23:16 Add Transitions to Other Attacks - Enemy.cs
23:58 Set up Objects in Unity Editor & Demo
25:12 Final Thoughts & Support LlamAcademy