Variable height jump with physics?

Get help using Construct 2

Post » Wed Dec 28, 2011 7:33 pm

Just a quick question.
I am using physics to make a platformer game. However I am not sure how to accomplish variable height jumps with physics (as in a long press means you jump higher than a short tap).
Basically it should work like this.
As you press space you apply an 'impulse' and immediately start ascending and decelerating. However whenever space is released, the vertical velocity needs to completely stop (i.e. advancing the deceleration).
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Wed Dec 28, 2011 8:13 pm

maybe while space is pressed add force a couple of seconds? , if you stop vertical velocity, it will stop moving abruptly, you should let the gravity control thisvtrix2011-12-28 20:14:02
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Dec 28, 2011 11:49 pm

I think you can use the same trick as what I use with the platform behavior

set a JumpCap instance variable (the value should be tweaked by trial and error)

and in event

[code]Keyboard: [invert] Space is down
LocalYVelocity < JumpCap
    -> set LocalYVelocity to JumpCap[/code]
Of course, you will have to calculate this LocalYVelocity which is a projection of the world-space velocity to the player object-space (or player-space).
And then you will have to convert the set LocalYVelocity back to world-space :D (lots of fun isn'it?)

Well if you look at the last capx I cooked for you you might find some ways

By the way, it's < JumpCap and JumpCap should be negative. It's the Vertical velocity you want your player to have if you release space and you're still under its value (which means you're still going up in player space). You don't cap to 0 to avoid too sharp transition but to a low negative value.Yann2011-12-28 23:52:03
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Mar 11, 2012 12:28 pm

Been trying to get this behaviour working as well. Any chance I could get to take a look at the capx?
B
4
Posts: 46
Reputation: 617

Post » Sun Mar 11, 2012 12:41 pm

I think the easiest way to do this is use impulse and every time you hit a key, eg. space, apply the impulse to your characterWeishaupt2012-03-11 12:41:37
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Mar 11, 2012 1:00 pm

Yes, Construct 2 is missing "Jumping Peak", what is common in my other game makers.
ImageImageImageImageImageImage
B
93
S
19
G
12
Posts: 1,209
Reputation: 18,357

Post » Sun Mar 11, 2012 1:10 pm

I think the way yann is describing it is the way I'd like to use it. just not exactly sure how to implement it at this stage. I sort of understand how to do it and will have fiddle around with it a bit later but I suspect my way of doing it wouldn't work so that's why I'm asking if he could share the capx with the rest of the community. :)
B
4
Posts: 46
Reputation: 617

Post » Sun Mar 11, 2012 1:55 pm

Well I did it by changing the behavior of the character from Physics to Platform.

Then, whenever space is released, and vectorY < 0, set vectorY to vectorY / 2.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Sun Mar 11, 2012 6:03 pm

That worked wonders. Thanks for sharing. :)
B
4
Posts: 46
Reputation: 617

Post » Sun Mar 11, 2012 10:52 pm

No problem ;)
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Next

Return to How do I....?

Who is online

Users browsing this forum: austinblackbelt, Matthew de, Skebab, spcsmrf and 6 guests