Is it a good idea to have one main master variable class for actors?
I am incredibly new to C++ and UE4 and was wondering: what is the best way to handle variables in a project?
I was thinking it might be a good idea to have a class full of variables where everything important is stored in the one place.
Think about a UE4 map, every object is stored in the map with details on where it is and how it is positioned, every object accesses that main 'master file' (the map) and gets information about where it's suppose to be (or the map tells objects, rather than objects querying for information). I was wondering if it is efficient (or even a remotely good idea) to have the same approach with variables; to have a 'master' class full of all important variables for objects/actors so that everything is stored in the one place and relatively easy to get to or reference.
Is this a good idea or does it just create unnecessary references in memory? Is this even good practice or am I thinking in an out-of-date fashion?
Any improvements on the way I'm thinking are extremely welcomed, Thanks guys!
In general, you want to have your variables limited to the scope where they are required. So variables that are only used by one class are included in that class. If the information needs to be accessed occasionally by another class, you can create a Get function to enable the other class to retrieve the current value of the variable (and a Set function, if necessary).
answered Sep 30 '14 at 07:52 PM
Tim C ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here