I created two classes, actions and conditions, each action has a list of conditions, conditions can be anything! If I want a character to have an action I just add it to their list of actions, the character checks all actions and executes the best one.
I didn't make any states and I just have a break and delay to prevent multiple states from firing, I use a canAct flag. My character class checks all the conditions for each action in the list and the 1st one to match gets called, then the flag gets set and I break out of the loop.
I have my actions list sorted so that the ones with the most conditions are checked 1st, that way pressing down and space will trigger before just hitting space. What I really like is how I setup my conditions, I used an abstract class as base so I can make anything a condition, a button press, requiring ammo, anything!
It's so easy to swap out different actions now!
0 comments