Hi.
I started programming in C# a few weeks ago and this is pretty hardcore stuff for me, some guy in unity answers sugested me I could use a FSM engine for my game so I searched the internet, found a few good sites with information about it (Unitygems.com) readed all I could read and I think I have a better understanding of what is this about. I think the concept its pretty simple and its pretty much based in logic
How I understand it (I could be totally wrong!):
Lets say we have an enemy, this enemy is in idle until the player gets close enough, when the player is close enough the enemy starts chasing the player, when the enemy reaches the player it attacks the player, so to my undestanding that would be 3 “states” the enemy has.
- Idle
- Chasing player
- attacking
(Dont laugh at my microsoft paint skills!)
FMS: Hey Mr.Enemy what are you up to?
Enemy: Idle
FMS: its the player close enough
Enemy:yes
FMS: then move towards the player and change state to “chasing player”
…
Thats the concept I got from reading about it (and I probably got it wrong).
However as much as i think I understand the basic concept the implementation and the code its what gets me, for example I want to have an inventory system for my game like in the old resident evil games.
In the inventory you can check, combine, use,etc the Items
Also in my game you can use two weapons at the time, one by default (regular left mouse button fires it) and other you can use by holding the right mouse button (while holding right mouse button and click on left mouse button fires it).
In the game there are three basic animations idle, run and jump
Each weapons has its own versions of these animations so I think idle, run and jump should be player states, and “item” or “weapon” should be too so the inventory system can identiffy what an object is but I dont know.
also should this be done in one script like a FMS that manages all the states of every object or should I have separate scripts for example one for objects weapons, other for like the inputs and so on?
Could also someone show me really simple FSM scripts(the ones on unitygems.com are really complex) , I would like to know how this things are done and how they interact with each other. The scripts doesnt need to work actually, it could be just descriptive code to see how things work.
Thanks