Choosing the jumping parameters of the platform behavior

0 favourites
  • 1 posts
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • As we know, the platform behavior can be used to control a character and make it jump, however something always bothered me, we have two parameters for the jump:

    JumpStrength and gravity

    While I understand the need for them (the Y position being calculated with a similar logic to :

    Y=0.5*gravity*relativetime^2 - JumpStrength*relativetime + InitialY )

    those are still unclear values for the actual person choosing it, we would rather set the height of the jump and how fast the jump is...

    And there are ways to do it!

    Just have this in mind, H is the height of the jump, T is the time to go from start of the jump to top of the jump, and calculate the values with:

    Jump strength = 2H/T
    Gravity = 2H/(T^2) = JumpStrength/T[/code:35nceqxs]
    
    You want a 300 pixels high jump that take 0.5 seconds to reach those 300 px?
    then you need 
    [code:35nceqxs]JumpStrength of 2×300/0.5 = 1200
    Gravity of 2×300/(0.5^2) = 2400[/code:35nceqxs]
    
    Of course, since the trajectory is not a smooth curve, but a discrete one (since C2 calculates the values at given times), expect it to be slightly imprecise with the framerate, and so do not have a 300px platform to jump on if the jump height is 300px, still a good ballpark figure that you can affect if you want.
    
    for those who want to calculate everything, not just the jump strength and gravity, here's the math part (you need to know two values to calculate the others):
    [code:35nceqxs]
    JumpStrength = T*Gravity
    JumpStrength = sqrt(2*H*Gravity)
    JumpStregth = 2*H/T
    
    Gravity = JumpStrength/T
    Gravity = (JumpStrength^2)/(2*H)
    Gravity = 2*H/(T^2)
    
    T = JumpStrength/Gravity
    T = 2*H/JumpStrength
    T = sqrt(2*H/Gravity)
    
    H = (JumpStrength^2)/(2*Gravity)
    H = JumpStregth*T/2
    H = Gravity*(T^2)/2[/code:35nceqxs]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)