Application.loadLevel seems like the scene was already playing

I have 3 scenes, when i change from the first to the second everything is alright. But when i change from the second to the third, it is like that scene has been playing all the time.

This third scene has enemies that spawn over time, and it’s supposed to star with none.
If I load it after the second scene ends there are several enemies.
If I load it directly after the first one, i has only a few.
When i change from the first to the second it starts from the start like it is supposed to.

So i gather from that, that only the third scene is playing on the background without being loaded or something like that.

can anybody tell me what is really going on and how to fix it? thanks in advance for any help.

Hi, what's your script for loading your new levels in each scene?

1 Answer

1

the one that changes from the first to the second is this:

private var offset : float = 0.25;
private var change : int = 1;

public var fade : GameObject;
public var chat : GameObject;
public var aim : GameObject;
private var canfade : boolean;

function Start(){
	renderer.material.color.a = 0.5;
	fade.renderer.material.color.a = 0;
}

function Update () {
	if(Time.time > change){
		offset += 0.25;
		change ++;
	}
	if(offset >= 1) offset = 0;
	renderer.material.SetTextureOffset ("_MainTex", Vector2(0,offset));
	
	if(canfade){
		fade.renderer.material.color.a += 0.5*Time.deltaTime;
	}
	if(fade.renderer.material.color.a > 0){
		chat.SetActive (false);
		renderer.enabled = false;
		aim.renderer.enabled = false;
	}
	
	if(fade.renderer.material.color.a >= 1) Application.LoadLevel(1);
}

the one that changes from the second to the third is kinda big, but it ends in this:

if(meuTempo > 84){
	Application.LoadLevel(2);
} (inside of update)

it’s mostly “if(meuTempo > x) do something” while meuTempo increases over time. if you still want i’ll post it all here.