Input getkey, keyup and keydown not working?!

Hello,

I am having trouble with the Input.GetKey commands, Input.GetAxis works fine.
Also the Input.GetKey(Keycode./* all combinations*/) doesn’t work.

My Code:

function OnTriggerEnter( col : Collider){
   nameText.SetActive(true);
   if(col.gameObject.tag== "Player"){
    Debug.Log("In trigger");
	if(Input.GetMouseButton(0)&& !showLoot){
	 Debug.Log("In trigger and clicked");
	 animation.Play("open");
	 yield WaitForSeconds(2);
	 showLoot =true;
	 _showLoot = showLoot;
	 PlayerInventory.isViewingOther = true;
	 PlayerInventory.inventory = true;
   }
  }
}

hope you can help me :slight_smile:

ButtonDown and Up -Events are only true for one frame. That’s why they are normally in Update() or OnGUI() functions. Think about it. Your onTriggerEnter function gets called in one frame. The key has to be pressed/released at this exact frame to get it to work. I would recommend you to put the Input stuff in Update or OnGUI and use booleans instead to get what you want to.