Jumping with Physics

Get help using Construct 2

Post » Sat May 11, 2013 6:26 am

Has anyone managed to figure out how to implement a proper modern jump system with physics for a platform game?

I'm currently using a system like this:

Space is DOWN
-----Jump =/ 0 > Apply Impulse to Player.Jump*45

Space is PRESSED
-----Jump = 0
----------Player is Overlapping Floor at offset (0, 10) > Set Player.Jump to 3

Jump > 0
----Every 0.1 seconds > Subtract 1 from Jump



With this system, you can jump at varying heights based on the duration of the space bar being pressed, and it won't jump while you're in the air.

The problem with this system is that if you have bounciness on (which looks weird with it off), it's difficult to set a jump if you're moving quickly and jumping from platform to platform. Also, you can "jump" off the sides of platforms. Also, the jump doesn't feel like a jump - it feels more like you're slowly accelerating up whereas a jump feels like a fast impulse (as if you were to just do a Space is Pressed > Set Impulse to X).

Does anyone have another system that would work for something like this?

Thanks!

B
22
S
3
Posts: 451
Reputation: 2,135

Post » Sat May 11, 2013 7:30 am

For the first question, make a variable called "canJump", and make it so that when the player is overlapping the floor at an offset, this variable is 10 (this number can be changed later).

Then, if he is not overlapping the floor and "canJump" is greater than 0, make it subtract 1, so it will go back to 0 very fast when it is not on the floor.
Now the jump event will require this variable to be greater than 0. This means you can jump even if you just left the floor or because of fast moving or bouncing a little.

With this you can remove the need of the variable "jump" you are using, and make the first event (the 'space is down') work only when "canJump" is 0, which means the player is already jumping or falling

---

For the second one, increase the gravity and the impulse you are giving you object. This will depend on your object's density, so play around with it.
In an old project of mine, a gravity of 50 and an impulse of 8 is enough for a very fast jump.
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sat May 11, 2013 8:57 am

Hmmm...I'm having trouble getting this to work properly. The problem is that when the player is overlapping with the floor, it continuously sets canJump to 10 depending on the offset. If the offset is set too low, it doesn't work properly with the bounces, but if it's set too high, the canJump variable stays at 10 until it's far enough "away" from the floor which results in random jump heights.

I tried adding a "trigger once" under the overlapping floor; set canJump to 10 event, but that seems to break it further...
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Sat May 11, 2013 6:45 pm

Ok I think I got the bouncing to work - the only issues with it now is that if you spam the space bar on first jump, it occassionally will "double jump" (not high, it's just not a smooth jump). Also, if you hold down the space bar, every time the player hits the ground, it immediately jumps again.

As far as the second problem I'm having with the accelerated jump - increases the impulse would mean I can't set it so if you tap the space bar, it does a small jump, and if you hold down the space bar, it jumps to its full value. That feature is pretty important in my game.

Any ideas?
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Sat May 11, 2013 7:19 pm

Can you send me a .capx so I can take a look?
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sat May 11, 2013 7:40 pm

Here is the example

Thanks, 7Soul!
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Sat May 11, 2013 10:38 pm

Can you upload it to dropbox? I'm getting 400 b/s from this link u.u

Also, when you reply to someone, use for eg @7Soul so I get a notification
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sat May 11, 2013 11:39 pm

@7Soul - Sorry about that; try this link:

PhysicsExample
B
22
S
3
Posts: 451
Reputation: 2,135

Post » Sun May 12, 2013 12:16 am

I think I got it:
https://dl.dropboxusercontent.com/u/3954039/PhysicsEx.capx
Only changed some events in the "UI" sheet, there are some comments there explaining what I did
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Sun May 12, 2013 1:00 am

@7Soul - Thanks for doing this. A couple things I noticed in this - if you spam space bar, it will do a double jump BOTH at an impulse of 8. Also, if you just tap it, the jump launches too high instead of something like super meat boy (ie. barely jumping off the ground). I'm wondering if it's impossible to re-create a platform like jumping system using physics?

B
22
S
3
Posts: 451
Reputation: 2,135

Next

Return to How do I....?

Who is online

Users browsing this forum: DemantDigitalArt, mjj1990 and 7 guests