Assume that i have 2 cube as the game object named
cube1 and cube2
and 2 transparency cube as collider named
co1 and co2
when the cube1 hit the co1 && cube2 hit the co2 = win game
Here’s My code of my MainScript
var Cube1: GameObject;
var Cube2: GameObject;
function Update()
{
Cube1 = GameObject.Find ("Cube_1");
Cube2 = GameObject.Find ("Cube_2");
}
function FixedUpdate()
{
if (C1.Collided == true && C2.Collided == true)
{
Application.LoadLevel("Level_2")
}
}
This is the boolean script for co1 and co2, another 1 assigned to co2 just change the cube_1 to cube_2
static var Collided = false;
function OnTriggerEnter (col : Collider)
{
if(col.name == "Cube_1")
{
Collided = true;
print ("Hit Cube_1");
}
}
function OnTriggerExit (col : Collider)
{
if (col.name == "Cube_1")
{
Collided = false;
print ("Cube_1 Left");
}
}
So now here’s the problem, when i play my Level 1, everything goes fine, when i load to level 2 and my cube1 and cube2 haven hit the co1 and co2, it just win the game straight away and load to level 3. But if i direct jump to level 2,everything works fine, This problem happens in other levels as well, can anyone help me?
P/S: Sorry for my broken english
Thank You!