I’m trying to make a script that the GUI (with a hint) becomes visible when enter collider. And when the player is IN the collider + he presses Z the animation climb ladder needs to play. My script:
#pragma strict
var IsInTrigger : boolean = false;
function Start () {
guiText.enabled = false;
}
function OnTriggerEnter(other: Collider){
if (other.tag == "Player"){ // remember to tag the player as "Player"
guiText.enabled = true;
IsInTrigger = true;
}
}
function OnTriggerLeave(other: Collider){
if(other.tag == "Player"){
guiText.enabled = false;
IsInTrigger = false;
}
}
if(IsInTrigger == true && Input.GetKeyUp(KeyCode.Z)){
animation.Play("ClimbLadder");
IsInTrigger = false;
guiText.enabled = false;
}