playMaker

Author Topic: Safe to use large amount of globals?  (Read 4261 times)

Krileon

  • Full Member
  • ***
  • Posts: 107
Safe to use large amount of globals?
« on: February 02, 2013, 07:53:06 PM »
I have many variables that need to be accessed from 3-4 different FSMs. Is it safe to use a lot of global variables? As Is I've about 12 and will need probably 5 more. Just want to make sure this is acceptable practice before moving forward. Performance seams perfectly fine so doesn't seam to hurt there.

nick_h82

  • Playmaker Newbie
  • *
  • Posts: 36
Re: Safe to use large amount of globals?
« Reply #1 on: February 04, 2013, 03:04:53 AM »
I'd be interested to know from a more technical standpoint as well- I've been publishing test builds of a physics-based game to my 3GS, with 12 global variables, and it seems to run ok.

The internal profiler suggests I'm getting around 32 FPS without much in the way of other optimisations. I briefly stress-tested by switching less essential actions to local variables and the difference wasn't noticeable, so I'd say go for it.

Krileon

  • Full Member
  • ***
  • Posts: 107
Re: Safe to use large amount of globals?
« Reply #2 on: February 04, 2013, 08:51:12 AM »
Yeah, seams to be my same conclusion. Makes things much easier when those variables need to be accessed from multiple FSMs, which is the point of global variables, lol.

Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Safe to use large amount of globals?
« Reply #3 on: February 04, 2013, 09:31:26 AM »
I have like 30+ and will be adding more. As far as I can tell it isn't an issue... Why would it be?
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Safe to use large amount of globals?
« Reply #4 on: February 04, 2013, 03:06:20 PM »
(tip: when using large number of variables or events, use "/" in their names to segregate them into categories. This helps A LOT)


Edit:
Quote
If you name your global events or variables using "/" for example:

"runtime registry / Players / local Player 0"
"runtime registry / Players / local Player 0 / health"
"runtime registry / Players / local Player 2 / selected weapon"
"runtime registry / MainCamera"
"game state / is paused"
etc.

Then selecting those in Actions' fields will be much convenient because they will be segregated in nice menu. (As far as I tested it works with Variables, Events, Tags and Layers!)
« Last Edit: February 05, 2013, 06:14:15 AM by Andrew_Raphael_Lukasik »

dasbin

  • Junior Playmaker
  • **
  • Posts: 92
Re: Safe to use large amount of globals?
« Reply #5 on: February 04, 2013, 04:11:45 PM »
I have a few hundred and it works OK. The resulting performance issues are in the editor, not the game. The global variable browser is very slow, and drop-down boxes in actions are a bit slow.

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Safe to use large amount of globals?
« Reply #6 on: February 04, 2013, 07:59:03 PM »
(tip: when using large number of variables or events, use "/" in their names to segregate them into categories. This helps A LOT)

Can't get this to work, could you explain what you mean by "use "/" in their names to segregate them into categories"

Cheers
Andrew

Andrew.Lukasik

  • Full Member
  • ***
  • Posts: 134
    • my twitter @andrewlukasik
Re: Safe to use large amount of globals?
« Reply #7 on: February 05, 2013, 06:13:22 AM »
Hi @LampRabbit
If you name your global events or variables using "/" for example:

"runtime registry / Players / local Player 0"
"runtime registry / Players / local Player 0 / health"
"runtime registry / Players / local Player 2 / selected weapon"
"runtime registry / MainCamera"
"game state / is paused"
etc.

Then selecting those in Actions' fields will be much convenient because they will be segregated in nice menu. (As far as I tested it works with Variables, Events, Tags and Layers!)

Regards,
A.
« Last Edit: February 05, 2013, 06:15:36 AM by Andrew_Raphael_Lukasik »

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: Safe to use large amount of globals?
« Reply #8 on: February 10, 2013, 07:31:58 PM »
Ah right. Thanks, that should help keep my global variables tidy.

I thought you meant it would do it in the globals window :P .. which is why it wasen't working :)