# How do I Calculate Jump Height?

Get help using Construct 2

### » Wed Aug 02, 2017 2:53 pm

When I touch screen. I want my player jump to "Max Jump Line".
I have bullet behavior on grounds.
I used platform behavior for jump.
Grounds have Jump-thru.

CAPX
https://www.dropbox.com/s/hu96mmyloaf1w ... .capx?dl=0
Last edited by OhhBaby on Fri Aug 04, 2017 7:55 pm, edited 4 times in total.
B
20
S
8
Posts: 49
Reputation: 1,407

### » Wed Aug 02, 2017 3:37 pm

Here is the formula you must use: V^2 = u^2 + 2aS which becomes: u = sqrt(2aS)
Where S is the distance, u is jump strength, and a is gravity, and v is the final velocity which in your case will always be zero.

Okay so this is how it will work, Make a Global variable called S, a , U

When user presses the Jump key/touch:
- set S to the distance from max jump line to the player(player.y - maxJumpline.y).
- set "a" to the gravity/9.81 of the player(player.behaviour.platform.gravity/9.81) ~ assuming that gravity = x * 9.81, you might fave to test this
- Set U to sqrt(2aS)
- Set jump strength to U
- Simulate player to jump
Free code for all
B
27
S
8
G
4
Posts: 63
Reputation: 5,146

### » Wed Aug 02, 2017 5:02 pm

x = 8 worked fine. Thx.
B
20
S
8
Posts: 49
Reputation: 1,407

### » Fri Aug 04, 2017 10:01 am

Reuben wrote:Here is the formula you must use: V^2 = u^2 + 2aS which becomes: u = sqrt(2aS)
.....

I have problems with walls. When my grounds going down and my player collide with any walls, It is problem. Do you know any solution for this?

1. I want this every time.

2. This is problem. I don't want this.

I tried pin behavior. It is sets position not looking good sometimes.
I tried gravity set 10000 this times when I try to jump it is not jumping to line.
B
20
S
8
Posts: 49
Reputation: 1,407

### » Fri Aug 04, 2017 5:53 pm

Sorry I am not sure what your are asking here. Are you saying that when the player hits the walls when jumping/while in jump the player does not reach the max jump line? If so, then are you using the "Bound to layout" behaviour? The "Bound to layout" behaviour messes up the jumping and gravity so instead just use 2 large beams with a solid behaviour on either side of the layout for the walls. To keep the walls in sync with the player, Just set the walls.y to player.y(assuming that the walls hotspot is in the middle for the walls)
Free code for all
B
27
S
8
G
4
Posts: 63
Reputation: 5,146

### » Fri Aug 04, 2017 7:10 pm

@Quasar

Please consider posting your .capx to cut down on pointless guesswork. It will be a benefit to you and anyone trying to help.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
142
S
32
G
89
Posts: 5,812
Reputation: 62,218

### » Fri Aug 04, 2017 7:54 pm

@zenox98, @Reuben

No, max jump line working fine.
My problem; when my player on floor and collide with wall; Platform behavior using "wall sliding". I don't want wall sliding.
I mean I don't want this.
B
20
S
8
Posts: 49
Reputation: 1,407

### » Fri Aug 04, 2017 10:18 pm

I spent some time trying different ways but still got no answer to this problem. I am sure there is some kind of way. But seeing that it probably nor going to be found you can always program you own platform behaviour(Not a new plugin or anything but in construct itself). I have had similar problems with the platform behaviour so I usually make my own, Here: https://freecode666.wordpress.com/2017/ ... -ceilings/
Complex platform behaviour without the construct 2 provide behaviour. Take a look at this and coppy some of the mechanics and add some.
Hope this works for you:)
Free code for all
B
27
S
8
G
4
Posts: 63
Reputation: 5,146

### » Fri Aug 04, 2017 10:42 pm

@Reuben
Thx for all. I will try that capx codes.
or
I will try to hack platform behavior for disable wall sliding.
B
20
S
8
Posts: 49
Reputation: 1,407

### Who is online

Users browsing this forum: No registered users and 25 guests