Must be the early morning or something, but I can’t seem to come up with a way that my Door trigger will go to the loading screen, remember what level I want to load, and when the second level is loaded, load the level… I’m probably thinking a bit too far, but I can’t seem to wrap how I want to get this right:
Note: Don’t worry about the talkMode and talking variables, I just ripped them from another code that I made as it’s doing nearly the same exact thing.
var IconTexture : Transform;
private var stayInTrigger = 0.0;
private var talkMode = false;
static var talking = false;
private var TextureShowing = false;
function Start()
{
IconTexture = Instantiate (IconTexture, transform.position, transform.rotation);
}
function Update ()
{
if (TextureShowing == true)
{
IconTexture.GetComponentInChildren(MeshRenderer).enabled = true;
}
else
{
IconTexture.GetComponentInChildren(MeshRenderer).enabled = false;
}
}
function OnTriggerEnter(player : Collider)
{
if(player.CompareTag("Player"))
stayInTrigger = Time.time;
}
function OnTriggerStay(player : Collider)
{
if(player.CompareTag("Player"))
{
if (Time.time > stayInTrigger + 1.00)
{
talking = true;
TextureShowing = true;
}
if (Input.GetButton ("Jump") talkMode == false talking == true)
{
talkMode = true;
MyWalkerController.isControllable = false;
talkDelay = Time.time;
}
}
}
function OnTriggerExit(player : Collider)
{
if(player.CompareTag("Player"))
{
talking = false;
TextureShowing = false;
}
}
The line
Is where I’m planning on loading my “loadingScreen” level. However, I want to have a variable named “levelToLoad” (which needs to be turned into a static var so my loading screen can pick it up) And then set that variable to whatever level I want (so if I… lets say set it to my Test level for the time being, I can). The Loading Screen will pick up this variable (ThisScript.levelToLoad), load the level in the background and when the level is 100% loaded, load the level.
After the level is loaded, it’s going to destroy that extra Door object as it no longer needs to hold onto that variable and is of no use, so once the level loads my other door object (to go back outside) will delete the extra door object (it’ll search for it, and if it’s there it’ll delete it, that’s simple though).
That’s what I’m going for, but the main problem that I have is, I don’t own Unity Pro, which means I can’t use the asynchronous load function which many of the loading screen topics suggest. I can possibly use “LoadInBackground” But either way I’m not wrapping my head around how I’m going to set it up.