Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Krileon 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.
-
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.
-
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.
-
I have like 30+ and will be adding more. As far as I can tell it isn't an issue... Why would it be?
-
(tip: when using large number of variables or events, use "/" in their names to segregate them into categories. This helps A LOT)
Edit:
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!)
-
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.
-
(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
-
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.
-
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 :)