[Solved] Is there a way to make a touch/click only happen once?

one more random question, hopefully this one will be a little simpler :slight_smile:
I’m making a node that materials will spawn on after a period of time. When the material is ready to be harvested, I want users to be able to press it to gather the item and set the animation of the node to “empty”, and then if they press it again it will switch to a “growing” animation. (I know that’s kind of dumb gameplay wise but for now that’s what I’m going for lol)

My problem is that even with trigger once on the relevant events, pressing the node bursts through all actions and immediately starts it growing again, because all conditions are being met and all actions happening before the player would stop pressing the object.

I was wondering about adding a 1 second timer that would have to pass before the next action can happen, giving people time to stop pressing, but I’m afraid quick clickers will feel like it’s delayed or buggy. Is there any other way to go about something like that?

You want a toggle-able state for the button. How to toggle states using Variables [GDevelop wiki]

You can easily solve it giving to your object a variable (object variable) associated with your timer. Like this…(supposing that each object will have their own timer)
Let’s name “Switch” the object variable, the object to harvest “Z” and the object timer “X”. Add an event with the condition: the object variable “Switch” of “Z” must be 0 and “Z” must get pressed to harvest. Add the action: start (or restart) the object timer “X” of “Z” and change the object variable “Switch” to 1.
Then…a new event that have the condition" "when object timer “X” of “Z” exceeds “(seconds you want)” action: change the object variable “Switch” of “Z” to 0. And eliminate the object timer “X” of “Z”.
Like this way your object will not be able to get pressed until your timer reach the seconds you want.

1 Like

Thank you so much :slight_smile: I’ll give both a try