How to spawn only one actor when button is pressed
Hi there!
I am having this problem and I can't seem to find a solution in the forums or in the many videos about similar topics. Here is my logic:
When Touch is Pressed and Attribute X is true then spawn a new actor on top of my old actor. After 0.1 sec, change Attribute X to false and Destroy old actor.
It works fine if I tap the screen, but it breaks if I hold down the button as the game spawns three or more new actors on top of my old actor. Is there a simple way to limit the spawn of a new actor to one per button press - even if the player keeps the button down?
Thanks for looking into this for me
-E
I am having this problem and I can't seem to find a solution in the forums or in the many videos about similar topics. Here is my logic:
When Touch is Pressed and Attribute X is true then spawn a new actor on top of my old actor. After 0.1 sec, change Attribute X to false and Destroy old actor.
It works fine if I tap the screen, but it breaks if I hold down the button as the game spawns three or more new actors on top of my old actor. Is there a simple way to limit the spawn of a new actor to one per button press - even if the player keeps the button down?
Thanks for looking into this for me

-E
Best Answer
-
IsabelleK Posts: 2,807
Just put a Timer on the spawn rule, so it looks like that:
Timer, every 0.5, or 1 sec.
When Touch is Pressed and Attribute X is true then spawn a new actor
I've done this in my games, when I needed to show dialog box once, and it was showing few times - like in your example.
There is also other way:
Make a new Boolean attribute - if the new actor is spawned, changed it to true.
And set up, that new actor is spawned ONLY when this attribute is false.
Hope this helps.
Cheers!
Answers