Allow keyboard input only if a condition is true

0 favourites
  • 4 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi everyone,

    I'm making a simple lander game to teach myself the basics of Construct2.

    The player's object (MarsLander) has a variable called Fuel. When Fuel <= 0, the player should not be able to control the lander. That is, the System should ignore the keypresses. Or, when fuel >= 0, the player can control the lander.

    What I want is this:

    IF MarsLander.Fuel >= 0

         do keyboard input

    What I have is this:


    System.MarsLander.Fuel >=0

    Keyboard.UpArrow pressed do stuff

    Keyboard.DownArrow pressed do stuff

    Keyboard.LeftArrow pressed do stuff

    Keyboard.RightArrow pressed do stuff

    But, that allows the player to move the ship around even if there is 0 fuel.

    Any guidance is much appreciated.


  • First off you don't need the every tick event. The condition is compared every tick.

    Second, add the keyboard conditions as sub events to the variable compare condition.

    If it doesn't evaluate to true, then the sub events aren't run.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks, Newt.

    Works great.

  • Thanks, Newt.

    Works great.

    Hi! Share please source. Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)