0
Under review

"If key just pressed" clause doesn't work

Dornano 6 days ago in Game Creator updated by Marti (Lead Developer) 6 hours ago 12

In a condition, the "Keyboard" clause seems to not working well.

If the state is "Being pressed", it works. But if it's "Just pressed" (same as "On key down" I guess?) it doesn't works.

(in my case, this condition is children of a "On Tag enter" Trigger)

Unity version:
Game Creator version:

Maybe you are looking for something that is in the hub

https://hub.gamecreator.io/content/item/HfEBp4iZY83YwI5lbqDK

Yeah I saw this in the hub. And indeed the "Being pressed" state is working, but not the "Just pressed", which is the one I would like to use :o

did you also tag the parent?

and also

exactly what is it you want to happen

there is also a player on enter key trigger that means the key will only react if the player is in the trigger

This is exactly what I would like to do (from 1:20) :


See? The player has a line in front of him, and if the line enters in a trigger (like a door, or something to examine) + if the Player press E (2 clauses), then an action is launched (open the door, display a message...).

Th Player don't have to be inside the trigger. But his line, yes.

+1

you could just put a new collider onthe player, set it in front of the player and set it as trigger.

Then you would have conditions on that trigger player enter tag and have tags on things you want the player to react with.

on player enter tag pickup

.....then...do some action

pn player enter tag doors

.....then...do some action

on player enter tag books

.....then...do some action

+1
Under review

Not sure if this is the case, but remember Conditions are just checked once every time the Trigger fires them. So if you have On Tag Enter, it will only check it once when the tag object enters the collider. Just one frame, not while the object stays inside.

Oh ok ok ! I was not aware of that, sorry.

Well, thanks both of you for your great help ! I managed to achieve what I wanted to do, after failing since weeks ^^;


Just in case someone would be interested, here is how I've done:

-I put a long invisible cube in front of my player with a "examine" tag.

-In front of my door, or object, anything I want an interaction with, I put a trigger with "On tag enter" set to "examine". When this tag enters, it sets a bool variable to True.

-Another trigger with "On tag exit" sets the bool variable to False.

-And a third trigger with "On Key down" on E, which refers to a condition: if the bool variable is true, it displays a message.


And voilà ! Now, it works exactly like in the video upwards. :D

Oh, Ok, that is actually how you standarly do it. I thought you wanted something different. But anyway you got it now working as you wanted it to be. Guod luck and have fun on your project. Any questions? we are all here to help and learn.

Yeah, this is the result:

Show message only when facing the door.mp4


See? I show the message only when the Player face the door. If I hit E key while I face in the other direction, it doesn't display the message, even if I am inside the trigger. That's why I needed this invisible cube with a tag ^^

Hi thanks, but I never download or open picture or video files from other sources. you could use youtube or a quick way is using streamable.com which give you 10 minute videos

Ah I think I understand. However, wouldn't it be better if the player rotated towards the door and then displayed the message? You could simply add a "Marker" where the arrow faces the door and in the Actions, before displaying the message, use the "Move Character To" to the Marker. That way you make sure the player faces the object.