playMaker

Author Topic: Many action on the same state or seperate actions?  (Read 1223 times)

puddlepouncer

  • Playmaker Newbie
  • *
  • Posts: 18
Many action on the same state or seperate actions?
« on: March 20, 2020, 07:22:17 AM »
Hi,

Just a quick little performance question. For clarity/neatness I prefer to separate some actions into different states and just use finished to pass through them.

Does this passing between states take up a lot of performance so its preferable to bunch all actions into one state instead?

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Many action on the same state or seperate actions?
« Reply #1 on: March 20, 2020, 01:55:30 PM »
You shouldn't experience any difference in performance. Source: have thousands of fsm's with a lot of states. Bear in mind not to make your fsm's too big in both states and actions since you'll be experiencing editor slowdowns.
Available for Playmaker work

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Many action on the same state or seperate actions?
« Reply #2 on: March 20, 2020, 03:23:52 PM »
Hi.
In theory there is a difference as the actions in the state need to finish before going to the next state.
A state will start all actions (from top to bottom) but it will not wait until the action is finished to start the next action (unless it is set as 'sequence' (right click action window to do this))

But this is so small that you wont even notice with 1000's of actions/states in build/playmode (But you can get lag in editor as Krmo said)

for myself it depends what the state has to do and naming makes sense.

Sometimes i have 20+ actions (like for some calculations)  in 1 state and some times only 1 (like a bool test for example)

Important is, always name your states in a way that makes sense.
Also use the description.
as one day if you need to get back to that fsm and have to change some things, you will know much faster what it does.

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 772
Re: Many action on the same state or seperate actions?
« Reply #3 on: March 23, 2020, 08:16:26 AM »
Hi,

Just a quick little performance question. For clarity/neatness I prefer to separate some actions into different states and just use finished to pass through them.

Does this passing between states take up a lot of performance so its preferable to bunch all actions into one state instead?

You would have to see with Alex or Jean. Going from state to state requires an event, even if local. This, no matter what, requires processing of some kind, even if minimal.
But as others have said, you would notice some loss in performance only if you had near a thousand loops within a FSM (by default you can't do 1000 loops but this limit can be changed although I wouldn't see the usefulness of doing this).

Using more states provides clarity but sometimes it's better to have a few actions packed inside a same state, if it really makes sense; that is, if all actions really do collaborate to do something that is topical and different from what any other state would do.
For example, calculate a float, convert it to an int and then set this as data to an event that you would send, all within the same state.

There's also the GOTO action which, iirc, consumes less TERAFLOOOPz than events. But it's dangerous.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Many action on the same state or seperate actions?
« Reply #4 on: March 25, 2020, 05:29:00 AM »
Hi,

 the passing between states has no performance impact, what has an impact is what actions in these states do on start and finish.

Bye,

 Jean