Jumping with physics behavior only?

Get help using Construct 2

Post » Tue Jun 17, 2014 11:30 pm

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?
Posts: 234
Reputation: 3,467

Post » Wed Jun 18, 2014 4:03 am

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.
Posts: 73
Reputation: 2,647

Post » Wed Jun 18, 2014 6:16 am

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.

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.
Posts: 10
Reputation: 245

Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek, Yahoo [Bot] and 7 guests