Heya
ifApplication.LoadLevel (Random.Range(0, Application.levelCount-1));
Loads a random level, How would I choose a random level specifically between Levels 3 and 10 (ignoring 1 and 2?
Thanks
AC
Heya
ifApplication.LoadLevel (Random.Range(0, Application.levelCount-1));
Loads a random level, How would I choose a random level specifically between Levels 3 and 10 (ignoring 1 and 2?
Thanks
AC
Application.LoadLevel (Random.Range(3, 11));
If you use integers, the random range function returns a number from the first to (but not including) the second. If you use floats, the function returns a number from the first to (and including) the second.
So I believe that code for a random level should be
Application.LoadLevel (Random.Range(0, Application.levelCount));
Or else there’s no possibility of ever getting the last level.
–Eric
Your so friggin helpful Eric 8) !
Seriously, if theres anything I can help you with art wise, let me know…I hope to have a fully licensed version of Maya within the next month…
That Space invaders clone perhaps?
PM me if theres anything I can do for you.
AaronC
At the moment I do all my own art, programming, sound, etc. If I ever learn to stop being such a control freak (it does make projects take a long time to finish), I’ll let you know.
Hang on–I’ve never done any character animation and I doubt I’d be very good at creating humans. So there’s that, if I ever do anything that needs people.
–Eric
@Eric-Im working on a few characters this year, so when ive got something worth showing I’ll let you know…
Now About levelWasLoaded:
My GO is an empty with an audio clip attatched. It also has a script marked dont destroy on load, and currently Im checking to see if a variety of levels were loaded in the Update function. I think this may be uneconomic. In summary, are awake or Start (re)called when a new level is loaded? If I could use either at the initialisation of a new level, that would seem to be more efficent than update.
Thanks y’all
AC
Instead of using an Update function (which gets called every update needlessly) why not use OnLevelWasLoaded instead? It gives you the integer index of the level that was just loaded and seems ripe for use in your example.
Edit: and to be clear, Awake() and Start() will each only be called once during the lifetime of the script.
Great Tom! Thanks
AC