• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Looking For Right Formula

Status
Not open for further replies.
Level 19
Joined
Oct 29, 2007
Messages
1,184
I am trying making a jump system that changes a units flying height in a lifelike way, without interference from the grounds z value. The jump increases the unit z with velocity v. Then gravity pulls the unit down with accelleration a=g. The problem occurs where the the terrain height from the start to the end of the jump changes. (The unit may be changing x and y while jumping.)

I think the formula for height h should be like this for each change in time t: h(t) = hunit flying height current + hchange in terrain from origin to end of jump + hvelocity v - hgravitity g

This, however, creates some very strange changes in the units z value where sometimes the unit u would jump 10 x its own height into the air, and other times it would hardly jump at all, given the grounds z changes from origin to end. Where the grounds z doesn't change, the formula seems to be correct.

Can someone help me adjust this formula correctly? I think I might not have the change in terrain z thing right.
 
http://www.wc3c.net/showthread.php?t=102077

JASS:
library ParabolicMovement2

    function ParabolaZ2 takes real y0, real y1, real h, real d, real x returns real
        local real A = (2*(y0+y1)-4*h)/(d*d)
        local real B = (y1-y0-A*d*d)/d
        return A*x*x + B*x + y0
    endfunction

endlibrary

y0 = z initial, y1 = z final. h = max height, d = total distance, and x is the distance from the unit's start to it's current position at that instance.
 
Status
Not open for further replies.
Top