- Home /
lose and win game
hello everyone! I would like to load a scene when my main character reaches the end of the game to let the player know he has won, and would like to do the same when he loses ( when he collides with a particular object) any ideas? ... thanks a lot!
Answer by MC HALO · Apr 25, 2011 at 04:33 AM
function OnCollisionEnter (Hit: Collision){
if(Hit.gameObject.tag == " Put your objects tag here"){
Application.loadLevel(" Put you level name here ");
} }
first thing is first you have to tag your player as "Player" then assign the tag to him. then copy the script add the tag as "Player" and then the level to load name and then save the script and attach it to the object that the player will collide with in order to bring up the win stage :)
Answer by crazyKnight · Apr 25, 2011 at 04:31 AM
function OnCollisionEnter(collision : Collision) { Application.loadLevel("name of the level to be loaded"); }
Answer by by0log1c · Apr 25, 2011 at 04:21 AM
If the question is "How do I load a scene?" , then you must add the scenes to the File > Build Settings list and then use:
Application.loadLevel(0); //use scene index
Application.loadLevel("GameOver"); //use scene name
yeah.. Ive done that already, I dont know how to load the scenes when he wins or loses... :S
my mistake, crazy$$anonymous$$night's answer is probably correct. Just make sure the collider you hit is the one initiating the game-over process.
Your answer
Follow this Question
Related Questions
physics.OverlapSphere colliders 1 Answer
How Can You Add Cut Scenes In Unity 2 Answers
I want to put an animated gif/avi sequence for a title screen. 1 Answer
getting a object to slowly orbit 2 Answers
Is there any way to change a scene while Handheld.PlayFullScreenMovie is playing a movie? 0 Answers