playMaker

Author Topic: Variables and Global Variables.  (Read 2573 times)

TIGGYsmalls

  • Junior Playmaker
  • **
  • Posts: 80
Variables and Global Variables.
« on: August 30, 2013, 10:47:16 AM »
Dose it make any difference at all if I use a Global Variable over a Variable or vice versa?


Lane

  • Administrator
  • Hero Member
  • *****
  • Posts: 2511
  • Mender of the past
    • Cleverous
Re: Variables and Global Variables.
« Reply #1 on: August 30, 2013, 11:02:37 AM »
It depends.

There are fundamental reasons to use a global, they're best used on a high level. If you're instancing the object that is making use of the global then its possible you'll run into a lot of issues with it because the same variable will affect many different objects. I've found them to be for a specific use, otherwise i use local variables.

It's also a factor when considering multiplayer, but I don't know a whole lot about the details there.

This thread shows some recent problems with them.
http://hutonggames.com/playmakerforum/index.php?topic=4738.0

Personally I didn't have much issues using them with high level scene changes or for storing data there but I avoid them for any character controllers, AI or unique objects. I tried it both ways on the early AngryShips design and using globals to control things on the character was slower than restructuring things to use local variables and just grab the ones I need from other FSMs on the character but I also made a lot of fundamental changes which could have affected the performance as well so it wasn't something I outrightly nailed down with a unique test.

There are a couple more older threads discussing them. I really dislike the refactoring time and only use them if it is significantly easier to design with that variable being global or if it would be saving a lot of calls from multiple objects looking for that data.
« Last Edit: August 30, 2013, 11:05:07 AM by Lane »
Products by Cleverous
|| Vault Core : Database
|| Vault Inventory : Multiplayer Inventory
|| Vault Attributes : Character Stats
|| That Hurt! : Dmg Floaties
|| Quinn : 3D

TIGGYsmalls

  • Junior Playmaker
  • **
  • Posts: 80
Re: Variables and Global Variables.
« Reply #2 on: August 30, 2013, 11:11:53 AM »
Ok , I don't think it will make much difference to me but it might just make my scene cleaner if I use a few more locals and call them.

Cheers.