hi there i was wondering if anyone could create or find me script to load another scene?
basically its to load a building interior(just another scene) from outside and obviously be able to exit(load my exterior scene) any help would be appreciated,thanks
thanks although when i collide with the object with the script attached nothing happens i have both levels in the build and yet no luck so far
p.s i have edited the script to load my levels of course and made sure that the tags are the same?
yup, they’re all right, you must use void OnTriggerEnter(other : Collider){}, check the name of the gameObject that has the collider other on it, so it’ll be the one you want (a.k.a. your player controller or whatever) then you have to make sure the collider placed in the opened space of the door has checked the “Is Trigger” option in the Inspector tab, and make sure you have a rigidbody attached to your player. and if you have many doors, you can add a switch case based on the door collider name or smt like this, to make sure you load the level you need.
for example you have 2 different doors which load 2 diff levels. let’s say we name the gameobjects to which we attach the colliders (trigger ones) door1 and door2… so door1 loads level 1 and door 2 loads level 2, and we’re in the level 0. make all the trigger colliders gameobjects named based on the level they need to load, and in your OnTriggerEnter() funcion do something like this:
if(other.name == "player"){
switch (gameObject.name){
case "door1":
Application.LoadLevel(1);
break;
case"door2":
Application.LoadLevel(2);
break;
//so on
default:
//do nothing
break;
}
}