playMaker

Author Topic: Finite State Pattern Question  (Read 1897 times)

Arialle Körsbärsträden

  • Playmaker Newbie
  • *
  • Posts: 6
Finite State Pattern Question
« on: February 04, 2015, 10:27:39 AM »
I am trying to make a fighting game and I was wondering what is a good design pattern for such. I have one finite state machine to handle all of the common states such as standing and jumping, and another for character specific actions. My problem is that I do not know a nice and clean way to send events at the proper time and state.


Such case examples are:
-the character can only shoot fireballs when in the standing state and is not doing any other move.
-the character can only perform a special move when in the air and isn't doing any other move.
-the character can perform an extra attack whenever the previous move collided with something.


One of my concerns is that I do not want one state being extremely large and overly bloated. Thanks in advance!

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Finite State Pattern Question
« Reply #1 on: February 04, 2015, 05:37:22 PM »
You would use conditional checks that would send events to transition to other states. Given your current setup I think you're going to have a really hard time doing that since you don't seem to be using any direct transitions and have opted for Global transitions. The design of Actions don't really lend themselves to this sort of FSM setup unless you deliberately dont need transition lines.

*edit: I dunno, I suppose you probably could do it that way, its just a matter of seeing whats going on with your conditions.
« Last Edit: February 05, 2015, 07:43:13 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Arialle Körsbärsträden

  • Playmaker Newbie
  • *
  • Posts: 6
Re: Finite State Pattern Question
« Reply #2 on: February 05, 2015, 11:59:17 AM »
I am still planning and working everything out in my head, but yes, I was planning to do some sort of conditional check based off of the mecanim FSM variables or something like that.

Just out of curiosity, why is using global transitions considered bad? I originally had lines going everywhere to the point where I was looking at spaghetti. I later refactored the FSM so that I can make the first screen capture a "generic" FSM template for every character in the game and then created a special FSM for unique actions. Whenever I needed the character to do a unique action, I simply get that FSM to send an event to the generic FSM to do the "Do Nothing" state. Whenever the unique action is complete, that FSM will go into the "Do Nothing" state and tell the generic FSM to do its normal stuff.

What I am lacking is figuring out a clean way to have the "State Entry" state figure out if a unique action needs to be performed.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Finite State Pattern Question
« Reply #3 on: February 05, 2015, 12:10:41 PM »
It's not considered bad, its just that regular transitions and global transitions have separate applications and it seems like this type of situation might benefit from some regular transitions rather than 100% globally driven.

It could probably work this way but it seems like it would be hard to control without a separate FSM dedicated to considering the conditions and dictating to these global driven FSMs. I did this with an AI before (info in this thread) and it worked out okay. I can't see how you're calling these global transitions so at first glance it appears like you would be making a lot of redundant actions in each state to bounce between them which is what the FSM that evaluates conditions would be taking care of.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D