How do I disable controls input while jumping?

0 favourites
  • 8 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hi, I want to create a platformer game. At first, I used Platformer behavior but I found that when character is jumping, I can freely change its direction mid-air, or if i release arrow key during jump, character stops moving sideways and drops straight down, which is very unrealistic.

    I want to disable control input during mid-air and also keep the momentum until it lands.(something like prince of persia, another world, etc.)

    I tried "start/stop ignoring input" actions, wasn't successful.

    please help me, thank you!!

  • Add another condition to the mirror event like this :

    Player is not jumping (Player is jumping then invert it)

    This will prevent the player from moving right and left while jumping.

  • A0Nasser, No it won't. Mirroring the sprite does not remove the Platform Behavior's inbuilt ability to change direction in mid-air.

  • moonsunglee So, what I did was make the input controls manual (toggling off default controls,) and then putting all of the manual controls under a condition, which is set on jumping. Take a look.

  • you can use a variable that acts as switch. Then add that variable as conditions for movement, so you can only use the right or left when the variable is a specific value. reset the variable's value when jumping/moving. For this, boolean-type variable can be good enough.

  • Unnatural20

    It's work perfectly

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • sgn15 I don't agree that a boolean variable is enough. With the built-in platform controls, you lose inertia as soon as you stop holding down the left or right inputs. A variable to maintain inertia and direction is necessary to model the behavior moonsunglee wants.

    A0Nasser As modelled in Prince of Persia, the question is not whether the direction the player is facing changes in midair, but whether you can control the direction of movement. Once the player has jumped in a given direction, he should keep moving in that direction until he lands or falls. Look at my .capx to see, at least, an approximation of the correct motion.

  • thank you Unnatural20! , your example worked perfectly! current speed affecting jump length is beautifully done.

    thank you A0Nasser and sgn15 also.

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