title: Implementing State Machine for Unity3D NPC characters
body: <p>I can't seem to wrap my head around this topic and i need a bit of a push forward, maybe an example.</p>
  
  <p>I'm currently developing a project including simulating a large number of automated characters trying to fulfill their "needs".
  As for now the characters have their need levels stored in their scripts as simple floating point &lt;0,1> value and check every frame if it exceeds a given value and then try to move to a defined point and satisfy their need.</p>
  
  <p>The problem is one character can have many needs and that leads to a situation when an character moves to satisfy one need and it drops just below the threshold it moves to satisfy the next need. Assuming that later i would like the needs to "rise" over time this will be a big problem. </p>
  
  <p>I <strong>think</strong> i should implement an state machine to transition from idle -> move to satisfy -> wait to satisfy -> idle but as i said i cant quite understand the whole state machine thing. The closest to understanding for me was this: <a href="https://github.com/nblumhardt/stateless" rel="nofollow noreferrer">https://github.com/nblumhardt/stateless</a> but I still cant wrap my mind around it.</p>
  
  <p>Would be grateful for any help, tutorials, examples, anything. </p>