Hi,
I’m making a simple game, were you have to destroy all the enemies in an small platform, before they destroy you, or the time reaches 0. Its basically a 3rd person shooter in an small “world”. I’m using C#
Right now, i have the basic mechanics coded (very dumb AI for enemies, destroy enemies, get killed, win and lose the game). I have some variables which are global across the scripts, but im not sure if my approach is good. For example:
I have a gameObject named “sceneInfo”, which has an infoManager script attached. This controls the text showed for the player (numbers of enemies, lifes and time).
But i also have a method which reset the game variables when you reestart the level (i.e win/lose and play again).
Is this a good approach? Which would be a good way to do it? or Where?
I think my real question is: Where is a good place to make scripts which have global variables? For example, the PLAYER_LIVES. Should they really be in the PlayerScript? So i show the numer of lives in the OnGUI() of the playerScript?
And the numberOfEnemies on the OnGUI() of the enemyScript()?
Is it better to have them all in the same place? Creating a gameObject to display that info is a good practice?
And what about reseting public variables that may be changed in the inspector? Is having a copy the only way of doing it?
Thanks a lot.