playMaker

Author Topic: how to make FSM do 2 things at the same time?  (Read 2115 times)

kici

  • Junior Playmaker
  • **
  • Posts: 63
    • KZ Development
how to make FSM do 2 things at the same time?
« on: May 19, 2014, 12:09:59 PM »
Here's my problem;

I have a start state checking for collision enter and collision exit

both sending its separate event,

however, if a specific "enemy" leaves "collision exit" the FSM will go towards that event and take care of whats happening, now in the meantime this is where my crysis happens a collision enters but because the FSM is focused on the exit part of the currently enemy, it does not recognize a new one entered and doesn't do what its supposed to on that side of the send events.

I realize I can add another FSM component, but is this the only way? what other options is there?

thanks.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: how to make FSM do 2 things at the same time?
« Reply #1 on: May 19, 2014, 12:15:35 PM »
Can you return to the start state and wait for collision enter again?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • My Blog
Re: how to make FSM do 2 things at the same time?
« Reply #2 on: May 19, 2014, 06:53:03 PM »
Simultaneous states either need you to add another FSM, or, finish up your other states before the next frame.

If you have no waits/nextframe actions, you should be able to pick back up where you left off.

You might also try sub-FSMs - but you still need to finish in less time than a frame- and get back to your original listening state.

EDIT: Assuming 'focusing on a different enemy' means your operations/events take longer than a fraction of a second- you should probably move the logic to the enemy.

Then you get a different instance of that logic per enemy. You wouldn't want to add extra FSMs to your listener/manager per enemy you have to manage.

Another Edit: However, you could use ArrayMaker magic, if you're really getting into managing lists.
« Last Edit: May 19, 2014, 06:58:52 PM by TrentSterling »

kici

  • Junior Playmaker
  • **
  • Posts: 63
    • KZ Development
Re: how to make FSM do 2 things at the same time?
« Reply #3 on: May 19, 2014, 07:12:47 PM »
Thanks a lot this really explaining a bunch, I did assume I might have to create a new FSM specifically for this enemy,

I guess this leads me to the next question, how can I make an FSM which will be called from this current one I have,

example if we are with Enemy5 (go to another fsm) and return to collision check (the other fsm will take care of what Enemy5 have to do)

thanks for the fast responses

Simultaneous states either need you to add another FSM, or, finish up your other states before the next frame.

If you have no waits/nextframe actions, you should be able to pick back up where you left off.

You might also try sub-FSMs - but you still need to finish in less time than a frame- and get back to your original listening state.

EDIT: Assuming 'focusing on a different enemy' means your operations/events take longer than a fraction of a second- you should probably move the logic to the enemy.

Then you get a different instance of that logic per enemy. You wouldn't want to add extra FSMs to your listener/manager per enemy you have to manage.

Another Edit: However, you could use ArrayMaker magic, if you're really getting into managing lists.