• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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