playMaker

Author Topic: Is there difference in time for executing actions split into several states?  (Read 304 times)

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 790
    • View Profile
    • Fat Pug Studio
Hi guys,

might be a silly question, but i need to ask. Is there difference in time for executing actions split into several states compared to all actions grouped together in one state? For example, will 10 actions in one state execute as fast as 1 action per state in 10 states?

blackant

  • Sr. Member
  • ****
  • Posts: 366
  • http://blackantmaster.com
    • View Profile
    • blackantmaster.com
it depends of actions complexity

if for exemple you ask to perform raycast everyframe in one action and another raycast  only 1/10 frame, the second will be less expensive.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 790
    • View Profile
    • Fat Pug Studio
For the sake of simplicity, let's presume all the executed actions are the same. And i'm not talking about how expensive the process is, more like is the time between actions in the same state of the same length as time between two states? So it's more of a theoretical question, with little real impact, but it would surely be useful to know if something would take 30 frames to initialize or 1.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 3523
    • View Profile
    • jinxtergames
Hi,
Lets say in the state, No every frame is used and action sequence is turned of.

When the state gets active it will 'Start' each action right after each other, from top to bottom.
It will not wait for each action to end.

But i believe it will only go to the next state when all actions are 'Finished' or if a send event is used of-course.

So if you would split the actions into different states, it would theoretically slower.

A state does not wait for a next frame, so you could have like 100 states looping in a single frame.
You could notice a difference when you use a lot states.

nFighter

  • Beta Group
  • Full Member
  • *
  • Posts: 119
    • View Profile
    • multiplayer adult fighting
But i believe it will only go to the next state when all actions are 'Finished' or if a send event is used of-course.

Actually, I'm facing a situation when it's not working like this. I'm not sure what exactly is happening, but it definitely don't wait for the action to end
http://hutonggames.com/playmakerforum/index.php?topic=19196.0
indie developer of multiplayer adult fighting
http://nakedfighter3d.com

Broken Stylus

  • Junior Playmaker
  • **
  • Posts: 78
    • View Profile
Hi!
The way I see it, aside from exceptional cases, separating actions into different finite states provides clarity and breakpoints but I haven't seen a loss of performance.

Unless you use a send "next frame event" action and unless I'm wrong, everything will be squeezed within the same frame and if you go too far, you'll hit the 1000 loops error thing (you'll notice frame rate dropdowns close to small hundreds of loops already anyway).

I suppose you could do a test with two dummy Fsms to compare the speed of both methods; one with all actions in one state and the other with several identical states with one copy of the same action.
I'd go with ten actions in the single state and in the second Fsm, ten states with a single idem action in each one of them, then loop both Fsms, add some counter and a display on uGUI text in both too at the end of the loop before it reboots, and run them; wait many seconds then full minutes and see which one seems to lag behind the other.

krmko

  • Beta Group
  • Hero Member
  • *
  • Posts: 790
    • View Profile
    • Fat Pug Studio
I'm not really worried about performance, more about keeping multiple FSM's in sync while having the clarity of a machine split into states. Anyway, testing sounds fun, i'll be sure to do it :)