- Home /
 
 
               Question by 
               LilacGear · Oct 12, 2014 at 02:49 PM · 
                javascriptcolliderstriggers  
              
 
              Trigger with get key down problems
What I’m trying to get it to work is a object with a collider on it. is trigger ticked. with a script that makes it so that when the player enters the collider, presses a button (“e”) then activates the gameobject. but also pressing e when the player isn’t in the collider does nothing. I’ve been looking everywhere and have no clue what I’m doing wrong.
java script
 #pragma strict
 
 var isActive : boolean = false;
 var jump : GameObject;
 var Seconds = 0.40;
 
 function Start (){
     jump = GameObject.Find("Jumpscare");
     jump.active = false;
 }
 
 function Update ()
 {
     if (Input.GetKeyDown("e"))
     {
         if (isActive == false)
             isActive = true;
     }
 }
 
 function OnTriggerEnter()
 {
     if (isActive)
     {
     jump.active = true;
     yield WaitForSeconds(Seconds);
     jump.active = false;
     }
 }
 
 
              
               Comment
              
 
               
              you mean when you are outside of the trigger pressing e doesnt make isActive to true if that is the case put a debug after setting isActive just to make sure it didnt change
Your answer