Different actions with the same Key (problem)

Hello,

I have a strange problem. First of all, let me explain you what I want from my program, and then the problem.

Well, there are two areas marked with “Area 1” and “Area 2” and there is a player in green.


When the player enters the Area 2, he has to press E to get a text onto his UI. Then, if he enters Area 1 and presses E, the door (blue object) opens.

My problem is, if I use button E at both areas it doesn’t work well. Area 1 works perfectly, but if the player enters Area 2 and presses E, the door opens. It’s like both areas do what only area 1 has to. If I use different keys (for example: I and E) for the different areas, they work well. What could be the problem and how can I solve it? Hope you understood me and can help.

Probably want to show your code for when you press “E”. The stuff you provided helps describe what you are experiencing, we just need to see how you’re setting it up to see if that is correct.

Many thanks for the fast answer, but I realised what I did wrong. I’m a beginner, and I made a big mistake. I didn’t use OnTriggerStay, just only OnTriggerEnter. Anyway, thanks for the answer, but I solved it. Have a nice evening!

Glad you got it figured out. Good luck with your game.