Hi! , I have stumbled across a problem i personally cannot figure out.
My problem sounds simple but i don’t know how to fix it .
In my scene , i have a crystal that the player has to collect , And then she has to get back to the "spawn machine "so she can get back to the main scene , But when my player collects the crystal , it goes back to the scene automatically , and the collider does not change to the spawn machine . My player needs to have the gem collected and then needs to go back to the spawn machine.
Here is my code.
var HasTutGem : boolean = false;
var TutGem : GameObject;
var GotGem : AudioClip;
var CGBTS = false; // can go back to spawn
function OnTriggerEnter (col : Collider){
if(col.gameObject.Find("TutGem")){
HasTutGem = true;
audio.PlayOneShot(GotGem);
Destroy(TutGem);
col.gameObject.Find ("ToTutRoom");
}
if(col.gameObject.Find("ToTutRoom")){
if( HasTutGem == true ){
CGBTS = true;
GoBackToSpawn();
}
}
}
function GoBackToSpawn (){
if( HasTutGem == 1 && CGBTS == true ){
yield WaitForSeconds (1);
Application.LoadLevel(12);
}
}