Animator State Machine AI
I'm polishing the Richter boss fight in the Night Market. I've achieved a decent AI by combining her animator state machine with her AI logic, augmented with external param-settings sensors and state machine behaviours. No external Unity assets required, and everything is modular.
Why
First question: why on earth would you do this, why not script it? Why combine the animator and the AI states?
- The AI is gonna be a finite state machine one way or another, we're not making neural nets here
- AI behavior decisions largely depend on which animation state it's in
- Visually editing the AI state machine is faster, easier to read, and easier to maintain than scripting a state machine
- I can make another boss fight with the resources here without writing a single line of C#
How
Here's how I implemented it, in 5 steps.
Step 1: Prototype the state machine on paper with the fight in mind. I want this enemy to be punish-based, so they're going to remain ~3 tiles away from the player if they can. If the player enters their zone, they'll either dodge or throw out a quick counter. If the player is still near them after a spacing modification, they'll throw out a larger, more mobile attack.
In the end-lag after an attack they'll be staggerable, so if the player can close the distance with a dash they'll be able to get a good combo off.
Step 2: Without making any of the actual animations, create the state machine in Unity.
Step 3: Hook up sensors that will set the parameters you need. The implementation of said sensors is left as an exercise for the reader.
Step 4: Add state machine behaviours to track simple things like movement and player orientation. Not shown, but I also have a "random transition in state" that will, you guessed it, instantly choose a random next state to play from a given list.
Step 5: Animate. I set fine-grained properties like staggerable frames during animations, instead of at the state level via state machine behaviours.
Step 6: Playtest and keep iterating :~)
Get Vapor Trails
Vapor Trails
Heartfelt game about revenge (on Steam!)
Status | In development |
Author | sevencrane |
Genre | Platformer, Action |
Tags | Cyberpunk, Metroidvania, Pixel Art, speedrun-friendly, Story Rich, Unity, vaporwave |
Accessibility | Subtitles, Configurable controls |
More posts
- STEAM RELEASEJan 29, 2024
- 0.18.10 UpdateOct 12, 2022
- Ghost AI for AndromedaSep 26, 2022
- 0.17.31 UpdateApr 02, 2022
- 0.17.15 UpdateMar 25, 2022
- 0.16.5a PatchMar 15, 2022
- 0.16.4a PatchMar 14, 2022
- 0.16.3a UpdateMar 13, 2022
- 0.16.2a PatchOct 08, 2021
- 0.16.1a bugfixSep 18, 2021
Comments
Log in with itch.io to leave a comment.
dude just played the demo this game looks and feels so good. i hope this becomes big game soon
thanks! I'll be pushing an update in a week, you should check it out.
Also if you're able to release this game on steam you should.
I think this game is gonna be a big hit one day! So keep up the good work and never give up! Because people like me are looking up to you!!!
Your words fill me with determination. Thank you.
i like how you're developing this game!
pretty cool!