Unity : AI && NavMesh [FSM : (Finite State Machine with Enum)]

NOTE : there is an incredibly useful shortcut to create switch statement with all the cases inside.

Type sw and Intellisense understand we want a switch statement, then press TAB two times, it opens a full declaration

Now inside we pass our variable _currentState, and press two times Enter

Really good shortcut!

if the Coroutine is called before it finishes executing its code, it resets itself from the beginning.

To handle this we use a bool.
And we use this bool inside Attack State and set the bool to TRUE



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matteo Lo Piccolo

Matteo Lo Piccolo


Always in love with programming, even if late (I'm already 39 years old) I decided to follow my dream! We will see how far my passion will take me!