Hello, I was wondering why this script didnt work? I want the scene to load when i collide with
the door and press “f”
public var change : boolean;
change = false;
function OnTriggerStay (player : Collider) {
if (player.gameObject.tag == “Player”){
change = true;
}
}
function OnTriggerExit (player : Collider) {
if (player.gameObject.tag == “Player”){
change = false;
}}
function Update(){
if ( change == true && Input.GetKeyDown(KeyCode.F)){
Application.LoadLevel(1);
}}
Make sure the script is on the door since you are looking for the tag player. Or put it on the player and look for a door tag
Function OnTriggerEnter(Player:other)
{
if(player.gameObject.tag == “Player”)
{
}
}
private var change : boolean;
change = false;
function OnTriggerEnter (player : Collider)
{
if (player.gameObject.tag == “Player”){
change = true;
}
else
{
change = false;
}
}
function Update()
{
//putting in a bool without stating true or false in a statement will make it defualt true
if(Input.GetAxis(“Opendoor”) == 1 && change)
Application.LoadLevel(1);
}
Try this, I don’t do java so if you see something that i didnt translate correctly sorry but i believe this should work