playMaker

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

kici

  • Junior Playmaker
  • **
  • Posts: 63
    • View Profile
    • KZ Development
how to make FSM do 2 things at the same time?
« on: May 19, 2014, 09:09:59 AM »
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: 2488
  • Yup.
    • View Profile
    • Cleverous
Re: how to make FSM do 2 things at the same time?
« Reply #1 on: May 19, 2014, 09:15:35 AM »
Can you return to the start state and wait for collision enter again?

TrentSterling

  • Junior Playmaker
  • **
  • Posts: 89
  • Someday I'll make games!
    • View Profile
    • My Blog
Re: how to make FSM do 2 things at the same time?
« Reply #2 on: May 19, 2014, 03: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, 03:58:52 PM by TrentSterling »

kici

  • Junior Playmaker
  • **
  • Posts: 63
    • View Profile
    • KZ Development
Re: how to make FSM do 2 things at the same time?
« Reply #3 on: May 19, 2014, 04: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.