- Home /
 
               Question by 
               nathanvj · Sep 07, 2013 at 10:45 PM · 
                animationontriggerenterontriggerexit  
              
 
              Whats wrong with this ladder climb script?
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;
     }
     
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by meat5000 · Sep 07, 2013 at 10:56 PM
http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerExit.html
OnTriggerExit( )
Try this instead of Leave
Your answer
 
 
             Follow this Question
Related Questions
Turret Script Error 2 Answers
OnTriggerStay and OnTriggerEnter won't react when the player enters them. 1 Answer
Can I instantiate a collision with a plane? 2 Answers
UCE0001: ';' expected. Insert a semicolon at the end 1 Answer
how do u add sound clips to an animation using animation events? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                