playMaker

Author Topic: Performance: Events arrays or global events  (Read 1528 times)

hipoh

  • Playmaker Newbie
  • *
  • Posts: 8
Performance: Events arrays or global events
« on: January 31, 2014, 10:04:16 PM »
Im confused as to what is the best practise in regards to performance for activating/deactivating and/or moving objects.

When you store an array of game objects, and then store a game object in a variable, is that bad for performance, i.e i have three game objects?

Whats the difference in sending a global event to a specific fsm, sending a named event, triggering an fsm bool and that object checking for bool changes, grabbing that gameobect from an array and triggering an event? There seems so many ways to do the same thing i've no idea which is best :-/

If you were deactivating children, would you use the next child action, loop through an array, store all children in a parent and deactivate that or send an event to the parent (with send to children) and have a deactivate-self action on each child?

Would you deactivate things at all, or just move them off screen?

AS you can see i could just do with some basic understanding of the overheads of different approaches.

Any help appreciated.





jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Performance: Events arrays or global events
« Reply #1 on: February 03, 2014, 06:24:52 AM »
Hi,

Im confused as to what is the best practise in regards to performance for activating/deactivating and/or moving objects.

When you store an array of game objects, and then store a game object in a variable, is that bad for performance, i.e i have three game objects?

not at all, no performance impact until you reach 100's of references, and more importantly, what's going to be done with them. that's more of a problem than simply keeping references in memory.

Whats the difference in sending a global event to a specific fsm, sending a named event, triggering an fsm bool and that object checking for bool changes, grabbing that gameobect from an array and triggering an event? There seems so many ways to do the same thing i've no idea which is best :-/


first, do what you seem logical and best fit, worry about optimzation later. I always apply this general rule, Too much optimization up front is a brake to productivity and generally totally inefficient. you have to produce before actually witnessing an area that could or must be optimized. Don't see that as a failure, but as the normal process... at least that's how I see it. So profiling is very important, don't develop for a long period of time without double checking it all runs fine, that would be the problem..

If you were deactivating children, would you use the next child action, loop through an array, store all children in a parent and deactivate that or send an event to the parent (with send to children) and have a deactivate-self action on each child?

Would you deactivate things at all, or just move them off screen?

I would suggest sending an event to all childs for them to deactivate. Actually, if that's a general behavior, I would create a dummy parent that I would deactivate and so all childs would be deactivated as a result, so insert a dummy parent inbetween your root and your childs and you only need to deal with one object to activate/deactivate, even better this way!!



Bye,

 Jean