Hi guys, How can i go about disabling an Input Key like “C” when I enter a trigger and enable it when I exit?.
You just need to check each frame, or at sensible points, if you are intersecting with that trigger. Then, change a variable based on what is returned. Your key press logic can then look for the desired value of that variable along with the input before it validates true.
I haven’t been doing program for very long so even though i can some what tell what you are saying I don’t know how I would do that.
private bool canDoAction = true;
void Update()
{
if(canDoAction == true && Input.GetKeyDown(KeyCode.C) == true)
DoAction();
}
void OnTriggerEnter()
{
canDoAction = false;
}
void OnTriggerExit()
{
canDoAction = true;
}
Thank you very much ![]()
Exactly that.
I have no idea how this works. I have a similar problem but I couldn’t get it to work. How did you do it. I want it to be when the trigger is entered, I can’t use the Left Arrow. I tried using what is provided but I don’t understand. Could you perhaps help me out?
Did ypu ever get your answer?? I also need to find out when the player is using left arrow keys the spacebar keycode is disabled so they cannot the spam, I used Instantiate script to the spacebar keycode
Thanks this helped me solve a bug I’m encountering ![]()