- Home /
Question by
troydhx · Nov 17, 2011 at 03:04 AM ·
optimizationvariablesmemberglobalvariables
Member vs Global variable speed
Hi,
Say I have a character object and several scripts that interact with it, is it better practice to have a member variable on each of these scripts that references the character object, or one global variable that they can all reference? I am developing for iOS.
Comment
Best Answer
Answer by aldonaletto · Nov 17, 2011 at 03:58 AM
I suspect there's no appreciable speed difference in this case. I don't know the exact implementation of globals (static public) in .Net, but in non-interpreted languages the difference would be essentially zero. On the other hand, a global variable would probably use less resources