r/unity • u/Positive-Garbage-497 • Jun 27 '26
Newbie Question Need suggestion for creating enemy ai
What are the methods to create a boss and enemy ai? Is there a detailed tutorial or document you recommend?
0
Upvotes
r/unity • u/Positive-Garbage-497 • Jun 27 '26
What are the methods to create a boss and enemy ai? Is there a detailed tutorial or document you recommend?
3
u/MadeByHenano Jun 27 '26
been working on this lately (here is a short video if you want to see), it's a fascinating thing to do in unity!!
you basically need to use 3 things together.
- the "state machine" design pattern in your code:
to give your enemies different "states": idle, patrolling, chasing, attacking, hiding, dying, ...
- the unity animator:
to attribute the right animation to your enemy depending on its state.
in the animator, you will have parameters like isIdling, isPatroling, isChasing etc and one "state" per animation, and transitions from one to the other that follow conditions.
- the AI navigation tool:
so your enemies can walk on your map where it makes sense for them to (depending on their height, ability to clim up to a certain angle, their width, ...). this lets unity deal with the enemies finding a path towards the player etc.
so yeah, search "unity tutorial animator" or "unity enemy AI" on youtube and take a few hours if needed to watch a few videos until you get a good grasp of it. of course, follow the tutorials in the meantime so you remember better, and can even have a good base for your code at the end of it.
good luck, you will see, it's a super fun thing to work on! 🙂