(If Space key is up, Spawn actor) spawning an actor before the first time Space key is pressed.

Hello everyone,
It must be an easy problem but I can't find the answer anywhere (maybe because is so obvious...).
I've set an actor to spawn another one when the space key is up (released) but as soon as the scene loads it immediately spawns the actor before the space key is even pressed for the first time. I know the keyboard keys are UP (released state) as default but I wish I could tell the spawner actor to ignore this first default state and only spawn once the space key is pressed down and then released.

Should be simple but I have very little experience and can't seem to find anything related in the forum.

Thanks in advance!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited October 2014

    Here's the tricky thing: When key space is up means "When the space key is not being pressed." It doesn't mean "When the space key is released."

    So the way to set up such a condition is to keep track of the when the space key is pressed. Create a boolean called self.pressedSpace and set it to false (unchecked). This could be a game attribute if you prefer, so that other actors can access its value. Then set up your rules like this:

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • WalkingkoanWalkingkoan Member Posts: 10

    I knew it was something simple like that! That make a lot of sense, thanks a lot!

Sign In or Register to comment.