- Home /
linking levels?
how do I link levels together? Say I want, when the character "falls off the edge" and falls for infinity, for him to hit a terrain that will load him to the next level, how can this be done? basicly I want a continuous loop of 2 levels I have created. when one falls from the edge of one, and hits the "under terrain", it will load the character to my next created level. this level does the same as the first, only loading the character to the original level...a purgatory of sorts (Don't ask, it's for an art installation). Can anyone help me with this. I have taught myself Unity and know the basics, but know nothing of scripts, and can barely navigate the inner workings of the software. can someone baby step my way through this issue? PLEASE!!!
Hi Damien, what do you need more than you asked here? http://answers.unity3d.com/questions/120083/how-to-link-scenes-.html Which bit are you having more trouble with? Chris
Thanks for the quick reply chris. So I've just added a cube collider, set it to triggger, changed my First person controller tag to "player", and put in the script mentioned here:
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");
PLEASE help clairify a few things? 1)"other is the collider"= do I change that name to "first person controller" if that is my name for my character? 2)set tag of player's mesh with a collider? is this done in inspector of first person controller under tag? 3) do I change maridiion to the name of my scene I wish to upload? I"ve just tried a few things but no luck so far. clarification on this script and how to implement it would be great. I'll even give a big shout out when my art show opens in early October :)
the script seems sound except i get the problem: Assets/NewBehaviourScript.js(1,34): BCE0018: The name 'collider' does not denote a valid type. I guess my main issue is what names(like collider) I have to substitute for my own eg. box collider, etc. what names mean what? is collider my player,or the box? also, when I put in my scene's name into the load level script...it's red. is this bad? I have saved it (build settings) with the rest of my scenes. the same goes for:
if (player.CompareTag ("First Person Controller Prefab")) return;
what should be in the parenthesess? my character name? or just player? player came up as an "invalid type" as well.... like I said, I'm new to this...:(
No problem, hopefully it can help. 1. See if this resource answers your question regarding the code http://technology.blurst.com/unity-physics-trigger-collider-examples/ Yes at some point as I understand it you name the object (in the example they are comparing tags). Yes you can set the object (cube) as a trigger in the inspector. Yes you will add the name of your scene where the maridiion is. Don't forget when you publish you will need to add both scenes to the build for it to work. Going to have to crash soon, its 3am here. :-)
yes the tag of your object (in your case player) can be set in the inspector.
Answer by em2 · Sep 05, 2011 at 02:06 AM
Hi Damien, sorry for the delayed reply, have been away from my machine. See where you are saying (other:Collider), "other" is the name you are giving to the object. Then you are asking it, is an object you have called player colliding with it, so that is causing your error becasue unity doesn't know what the player object is. Try changing (player.CompareTag...etc to (other.CcompareTag...etc. Make sure that you have set your game object that is being collided with i.e your cube (and it is also the one you put this script on) is ticked as "is trigger" in the inspector.
Use this:
function OnTriggerEnter (other: Collider){
if (other.CompareTag ("Player"))
Application.LoadLevel ("Painting2");
}
Cheers Chris
Hi Damien, can I suggest that you maybe edit the name of your question so it would be more easily found in a search by someone having a similar problem. If this does solve it, it would be great if you can accept answer, it also helps others to find it. Cheers Chris
Thank you Chris. I finally got it to work. much appreciated. Lesson well learned. You will definitely be getting some cred during my artist talk in october. visit my website if you like: http://www.wix.com/damworth/damien-worth
No problem Damien, thank you, glad it worked. All the best with your presentation. Will check out your site. Cheers Chris
Answer by em2 · Sep 02, 2011 at 02:46 PM
Have a look at OnTriggerEnter in the unity documentation at http://unity3d.com/support/documentation/ScriptReference/Collider.html , as I expect you could add an object for your falling character to hit (trigger) to launch your next scene. Then implement in reverse in the next scene, where the trigger loads the first scene again. You will also see the trigger check box in the inspector panel. Hope this helps. Cheers Chris
I should have also included load level at, http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html
Chris
Your answer
Follow this Question
Related Questions
Problem to go to another world scene in level select lock/unlock 0 Answers
Can I utilize LoadLevelAdditive for immersive game? 2 Answers
Load Level on Collision 1 Answer
Allow userto load custom unity levels/scenes. 2 Answers
How Do I Exit Level? 1 Answer