Hello to the unified …
Just a quick question … how would I pass info collected in one scene on to another scene.
ie game stats … without the use of www or url … I can’t seem to find any documentation on it … could someone either point me to the doc or spell it out for me?
Cheers … DontDestroyOnLoad works a treat … which brings me to the next Q … how do I now clear the data when I reload the original scene … to test to see which level is loading before running the DontDestroy script?
What’s the correct syntax for that?
I use global variables that are in a GameController object that doesn’t get destroyed during level loads. I attached the gameController script to an empty game object in the very first scene.
At any time during the game I can pass a new variable (say, a reset number) back into the global variable in the GameController. Here’s a simple code example …
/* ----- Use global variables for stuff you ned to keep track of throughout various game scenes ----- */
static var instance : GameController;
static var currentScore : float = 0;
// the variables for the different levels
// these are loaded into the game scene when the player is in the start"Name" scenes and selects easy, medium or hard
static var playerLives : float = 0;
static var enemyCount : float = 0;
static var shipsLeft : float = 0;
static var somethingElse : float = 0;
Then I can reference these from inside any scene by referring to GameController.playerLives for example.
Hi to the unified …
Here’s a link to the web player of the project, (http://www.az.suiteaz.com/fluid/?q=node/35) basically it’s a project I created to help me learn a bit more about scripting, modelling and UV mapping. I’ve used Yoggy’s car engine script to help edumecate meself with, (thanks Yoggy for making that available). The method of creating a GameController (Thanks DaveyJJ) with a DontDestroyOnLoad (Thanks yellowlabrador for pointing me to the documentation on that) was an excellent way to pass the variables from scene to scene … (basic though my use of it is, it certainly was educational) … so anyway the webplayer is a very simple (1 track, 1 car, simple textures, simple collsions … etc) racing game. It’s kinda adictive somehow. So if you have a minute … take it for a spin. (Of course any feedback is more than welcome).
p.s.
I’ve become curious about the proccess used to manage large “multi scene” web player games … can you selectively load scenes as you need them? eg A multi track game where the user might choose which track to play … then load the apropriate scene/track … or a multi level game … where the levels are loaded when the user reach’s them but not before? or what other methods are used? Do people generate the meshes on the fly then load textures from a URL? …
Thats wicked mate.
This is the best car demo Ive seen yet, it just feels solid. You did a great job of texturing the track too.
Very professional…Good stuff.
AC
Of course I can’t take all the credit for that as I think some of the credit should go to Yoggy for his car script, and then of course some to the makers of unity3D for making such a kick ass program.