- Home /
how to link scenes ?
I am looking to link 2 or 3 scenes together so that when you "fall off the edge" to a certain depth, you will jump (load) to the next level? can this be done and how? Also, at the last scene of the sequence, when falling off its edge, I want it to link back to the first scene. a sort of eternal loop thing. how do I link scenes based on the "falling off for eternity" thing? any help would be great, thanks!
Answer by DaveA · May 22, 2011 at 02:49 PM
Make a gameobject with, say, a CubeCollider (any collider will do), set to 'is trigger' and script the 'OnTriggerEnter' to use Application.LoadLevel. Place the object/collider where it will 'catch' the falling player. When they fall into it, it will switch scenes.
Answer by Kiffster11 · Apr 28, 2012 at 12:18 PM
is there a code to change scene's on a mouse click, i want to go from my Scene 1 to Scene 2 by clicking on a certain cube
Answer by Damien78 · May 24, 2011 at 12:23 AM
thank you so much for your help here. I am still new to unity and am having trouble with these scripts. I set my cube collider to "is trigger", but am unsure how to script the "on TriggerEnter" to use Application.LoadLevel. Also,where do I type in the level in which I want the character transported to? is it eg. Application.maridiion(if this is the name of the level)? Sorry for the noob questions, I'd just really like this to work.
I can't even find where the "OnTriggerEnter" option...or is this just a simple script?
help please
Answer by save · May 24, 2011 at 12:43 AM
Instead of writing your new question as an answer here you can use the comment below an answer to question it - otherwise it'll get confusing for other people that is looking for a solution.
It sounds like you need to read up on the scripting reference, give it some time and you'll get the hang of it. The OnTriggerEnter and Application.Loadlevel works like this:
function OnTriggerEnter (other : Collider) {
/*other is the collider that enters the trigger area
we first check if the collider is the player (set the
tag of the player's mesh with a collider to "Player")
if it's not the player then return (escapes the function from below the return-line)
*/
if (!other.CompareTag ("Player")) return;
//Load the level
Application.LoadLevel ("maridiion");
}
This code is using javascript (so you create a js-file from unity, put the code into it, drag the file onto the object - or in some cases reference to the file from other scripts). The manual will get you started with these basics.
Although it sounds like you might want to look at a solution for looping your scene instead of loading levels, there you could either look at additive loading scenes onto your scene, the transform position of each gameobject or instantiation of new while you destroy the already passed.
Your answer
Follow this Question
Related Questions
How do I change scenes from triggers in UNity 1 Answer
How to teleport to different scenes? 2 Answers
Reduce 'Levels' or Scene File Size 1 Answer
Online levels database 0 Answers
Unity game level design patterns 0 Answers