- Home /
Question by
legoguy217 · May 25, 2012 at 08:33 PM ·
scenerandom
Randomly select a scene
For example, I want it so when the player collides with an object, it then gets sent to a random scene. Here's a code that I failed to make. Can anybody make a script for that reason?
var LevettoLoad : String;
function OnCollisionEnter (Collison : Collision) {
if(Collison.gameObject.tag == "Player")
{
Application.LoadLevel (Random.Range(0, Application.levelCount-1000));
}
}
Comment
First, don't ask others to do the work for you.
Second, why the heck do you subtract 1000 from the level count? If you remove the -1000 it should work...
Answer by Bunny83 · May 25, 2012 at 08:37 PM
Search functions are really not that bad...
http://answers.unity3d.com/questions/57624/random-load-level.html
http://stackoverflow.com/questions/4950078/how-do-i-load-random-levels-in-unity-3d