how to load multiple levels within one scene

Hi there i have a scene where i have boarders to load to another scene and a cave in the middle to load a cave scene, only it doesn’t work… iv done the scripts and tagged the right colliders for when the character hits it but the problem is it only loads one of the levels even though one of the colliders is tagged as Level_Load_caves_01. I cant think of the reason why this could be?

Here are my scripts, script one is to go to SP :

using UnityEngine;
using System.Collections;

public class Load_Level_wastelands_01 : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
void OnTriggerEnter (Collider other)
{
if (other.tag == “level_load_wastelands_01”);
{
Application.LoadLevel(“SP”);
}
}
}

script two to go to Caves :

using UnityEngine;
using System.Collections;

public class Load_Level_Cave_01 : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
void OnTriggerEnter (Collider other)
{
if (other.tag == “level_load_Cave_01”);
{
Application.LoadLevel(“Cave_01”);
}
}
}

Both are attached to the character but they both only work without the other one, so then i thought i would combine them into one as follows :

using UnityEngine;
using System.Collections;

public class Load_Level_wastelands_0 : MonoBehaviour {

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}
void OnTriggerEnter (Collider other)
{
if (other.tag == “level_load_Cave_01”);
{
Application.LoadLevel(“Cave_01”);
}
{
if (other.tag == “level_load_wastelands_01”);
{
Application.LoadLevel(“SP”);
}
}
}
}

But no luck either, big headache, any help would be appreciated, thanks.

First things first: Use

 tags..its the little hashtag symbol above the textbox.

Does it load the same map from both triggers or only from one while the other is not working?
It would also be alot easier if youd just write a script that has a

public string mapName;

which you use in

Application.LoadLevel(mapName)

and apply that script to your triggers and set the mapName variable in the inspector accordingly and jsut check for tag == player

Thanks for the reply. Yeah they both load the same map from both triggers, but i know they both work.
So I could set a script up on the triggers them selves to go to a level? that would be much easier, only i wouldn’t know how to other than what you have put there, unless that is all that needs to be put? (with map names) as for tags you have completely lost me, i'm still in the learning stages.

ahhh i see, I will use it next time :slight_smile:

No matter people iv got it sorted now I done this script and attached it to the collider and changed the map names to go to :slight_smile:

 var theLevel : String;

 

function OnTriggerEnter (myTrigger : Collider) {

 if(myTrigger.gameObject.name == "player"){

 Application.LoadLevel(theLevel);

}

}

Thanks for the help though, appreciated.