playMaker

Author Topic: What's the best way to slow down Playmaker?  (Read 4596 times)

courtneyrocks

  • Playmaker Newbie
  • *
  • Posts: 8
What's the best way to slow down Playmaker?
« on: February 25, 2014, 12:43:39 AM »
I saw a topic on a Unity board about the best ways to make your game run slow by scripting badly and I thought it might be good to see the same thing for Playmaker.

I use Playmaker a lot  (love it) and I wonder how if I could make my games run faster.

So I thought if I knew how to make my game run really slowly then I could make sure to avoid these things in my next game.

So let's make a game that runs really slow by maybe:
Using lots and lots of strings?
Comparing lots of strings?
Debugging as many variables as possible?
Checking as many variables as possible every frame?
Does using lots of global events slow things down?
Does using Arraylists slow anything down?

Thoughts,
C

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #1 on: February 25, 2014, 03:10:16 AM »
Hi,

 Lots of string doesn't slow down anything, it's what you do with them.
Comparing lots of string is ok, don't expect performance issues here.
Debugging is only an editor thing, so this is not affecting your game at all.
Checking variables is ok, this is the core of programming, so you are fine.
Global events do not slow down things more then non global events.
ArrayList do not slow down things, it's what you do with it. If you do do too much work on them for a given update, then yes, it will slow down for sure, but that's not really related to the arraylist itself but more in the total amount of work you do as a result of having a long list or heavy operation on each entries of that list.


As always, I think it's important to realize that your game is going to struggle more because of wrong shaders, bad mesh optimizations, wrong quality settings ( user's own choice, but still, resulting to bad perfs) for a given machine, too much shadows or bad lighting technics.

When all this is sorted and efficient, then you can tackle programming refactoring. However, se few pitfalls should be avoided at all costs.

-- Collisions and triggers detection: this can lead to very bad perfs if not carefully monitored
-- using "find gameobject" only with string. Avoid that at all costs, Unity doesn't provided an efficient way to do this, prefer searching by tag instead or better keep a propery reference. IF you must use Find, do it once only and store a reference don't do this on every update or even twice.


bye,

 Jean

courtneyrocks

  • Playmaker Newbie
  • *
  • Posts: 8
Re: What's the best way to slow down Playmaker?
« Reply #2 on: February 25, 2014, 04:06:44 AM »
Thanks Jean!
C

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: What's the best way to slow down Playmaker?
« Reply #3 on: March 18, 2014, 09:10:52 AM »
Hi Jean,

Please explain this a bit:
"Collisions and triggers detection: this can lead to very bad perfs if not carefully monitored"

What do you mean by carefully monitoring?

The reason I came here was that I am experiencing the editor slowing down to a stop when a lot of trigger events happen. I see thousands of OnTriggerEnter, Stay, Exit 2D events every second in the console, but I'am only using a fraction of those in my FSMs.
The project runs smoothly on device thought.

How can I get rid of these unnecessary events, so they don't slow down the editor?
Hard to test and debug because of them.

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #4 on: March 18, 2014, 09:13:53 AM »
Hi,

 ok, what actions are you using? is it the unity 2d framework? you can turn all debugs off on the various proxies you have on your gameobjects.

 I mean by careful monitoring that indeed you don't create use trigger stay whenb you don't have too and that you don't implement unecessary trigger events in your fsm. Clean up your fsm if you don't need them typically.

bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: What's the best way to slow down Playmaker?
« Reply #5 on: March 18, 2014, 09:34:14 AM »
I'm using only Trigger2D Enter and Exits. no Stays.
Yes Unity 2D.

"you can turn all debugs off on the various proxies you have on your gameobjects"
I don't understand this. (Searched for proxy/proxi in the playmaker manual but did not find anything.)

The console is still flooded with TriggerStay2D events after I uncheck everything in Playmaker's Preferences\Debugging.

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #6 on: March 18, 2014, 09:47:01 AM »
Hi,

It's not a plamaker prefs it's a public variable int he proxy you have on the 2d gameobject itself.

check the "PlayMakerUnity2DProxy" component and set "debug" to false.

bye,

 Jean

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: What's the best way to slow down Playmaker?
« Reply #7 on: March 18, 2014, 10:04:43 AM »
In my experience the best way to cause playmaker to tank your performance is to poorly implement logic loops and management.

A simple system might work fine for one particular object but if you plan to scale that into a whole bunch of instances in the scene at the same time you really have to polish how and when they get information and spend some time building a very efficient system, or even high level managers to replace that instead.

For example I started using Next Frame Event as an interrupt to keep from getting the 1000 loops exception but really, the issue was that I designed a bad logic loop to begin with and Next Frame Event was just a crutch. The AI couldn't be efficient or intuitive if it was constantly stuck in that same loop. Rebuilding the system to be more intuitive and not rely on that cycle improved performance, consistency and reliability. Even with loaded Spherecasts every frame I tested 30 agents in a congested scene at 260 fps with the improved system.

So I feel like the biggest contributor to lag from playmaker is caused by poorly designed FSMs and FSM groups since I've seen this take place in my own designs and fixed it by designing better systems. I think this makes a much bigger difference than sheer quantity of data up until you get to a certain point.
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #8 on: March 18, 2014, 10:14:56 AM »
Hi,

 I agree with Lane here. Also, after this is sorted out and cleaned up, you can still find yourseful using an action that is known as slow, typically

-- create object ( hence why you should use a pool manager when you deal with lots of object creations at runtime)
-- find gameobject: do use tags to help unity filter out the search, this can REALLY slow down your game, so be very careful with it and prefer one time operations or even hardcoded Fsm vars pointing to the right gameobject to begin with.
-- excessive "STAY" triggers and collisions events.
-- moving/translating physics objects as opposed to using forces

that's the main ones coming to mind today :) typically, you should profile your game to find what is the bottle neck, that's the best way to go about it.
 
 Bye,

Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: What's the best way to slow down Playmaker?
« Reply #9 on: March 19, 2014, 03:24:37 AM »
Thanks Jean and Lane for things to look out for.

I think I have none of those problems, just the constant logging of trigger stay events, I don't even use.

"... it's a public variable int he proxy you have on the 2d gameobject itself.
check the "PlayMakerUnity2DProxy" component and set "debug" to false."

1.
I don't have this proxy on any of my gameobjects as I don't use global events, I just use Trigger 2D Event actions in their FSMs and wait for On Trigger Enter 2D.
2.
Even if I add this "PlayMakerUnity2DProxy" component to an empty game object, there is no public variable where I could set "debug" to false.

What else should I check or change?

Thanks,
Peter

edit: just noticed that the "PlayMakerUnity2DProxy" component gets added at runtime to my objects with 2D triggers.

Should I add this manually before? But I am not using the global collision events. It's only required for those, as stated here: https://hutonggames.fogbugz.com/?W1150
« Last Edit: March 19, 2014, 04:21:28 AM by purbanics »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #10 on: March 25, 2014, 07:30:13 AM »
Hi,

 this proxy is added only when needed, typically if you use actions like "Collision 2d event" or else, you have to manually add it if you implement a global event, but this is not the only case where a proxy is required.

 please download the pacakge from the wiki again, I have set the debug flag to fals by default so automatically added proxies won't spam your log.

 Bye,

 Jean

purbanics

  • Junior Playmaker
  • **
  • Posts: 55
Re: What's the best way to slow down Playmaker?
« Reply #11 on: March 25, 2014, 09:00:36 AM »
Thanks Jean, works great!
No more frame rate drops/unnecessary log spamming.

So, the proxy is automatically added where required, but then I guess it would be better to add it manually before, to these objects that will require it during runtime anyway. Right?

Br,
Peter

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: What's the best way to slow down Playmaker?
« Reply #12 on: March 25, 2014, 09:06:45 AM »
Hi,

 yep, you are right, it's better to have everything setup to avoid hickups.

bye,

 Jean