Jumping with physics behavior only?

0 favourites
  • 3 posts
From the Asset Store
Jump on candies, collect candies and earn score!!!
  • I'm working on a physics based game and I'm trying to figure out how to allow players to jump, but not jump when they are in the air.

    That is easy enough to do by itself, but I'm not sure how to prepare that for the case when they fall off a ledge.

    For instance, if the player touches the ground, they can jump. If they jump, they can't jump until they touch the ground again. But there's no event for detecting the lack of a collision happening, so I can't make the player unable to jump after they walk off a cliff.

    Is there any way to fix this only with the physics behavior?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Instead of saying "Don't jump when you are in the air" think of it as "Only jump when you are on the ground". So you could create an event with two conditions: Is overlapping (ground) & Keyboard (Jump) pressed. Only when both are true would you apply an impulse to make the player jump.

    Another option: when you jump off the ground set a variable to prevent the player from pressing the jump button again until the next time they collide with the ground.

  • Another option: make a check for a change in the player's Y movement every time the player presses the jump key. If their Y changed in the last tick, jump is not available.

    Pseudo:

    on Keyboard press UP

    -- set variable jumptest to player.Y;

    -- Wait (0.01 sec);

    -- Compare jumptest to player.Y;

    -- if jumptest equals player.Y, process JUMP

    EDIT - this may become problematic with vertically moving platforms, but can be solved by also checking for collision with said platforms.

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