Let’s say that there are 2 objects: Activator and Gate.
Activator has a script called [“ActivatePortal”].
Gate has a script called [“Portal”].
I need Activator script to activate Gate script.
So if Activator script [“ActivatePortal”] is not somehow activated, you cannot activate Gate script [“Portal”].
ActivatePortal script:
var script: LoadNextLevel;
function OnTriggerStay (){
if (Input.GetKeyDown(KeyCode.JoystickButton1)){
script = GetComponent(Portal);
script.enabled = true;
Debug.Log("Sucessfully activated!");
}
}
Portal script:
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "Player"){
Debug.Log("Player went through! Level2 loaded.");
Application.LoadLevel("Level2");
}
}