1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Looking For Right Formula

Discussion in 'Triggers & Scripts' started by Megafyr, Dec 23, 2010.

  1. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    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.
     
  2. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    http://www.wc3c.net/showthread.php?t=102077

    Code (vJASS):
    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.
     
  3. D4RK_G4ND4LF

    D4RK_G4ND4LF

    Joined:
    Feb 4, 2009
    Messages:
    1,196
    Resources:
    20
    Models:
    3
    Spells:
    15
    Tutorials:
    2
    Resources:
    20
    I wrote a tutorial about it some time ago
    (see signature)
    Code (vJASS):
    function GetParabolaZEx takes real x, real d, real h, real z0, real zd returns real
        return 4 * h * x * (d -x) / (d * d) + x * (zd-z0) / d + z0
    endfunction
     
  4. Megafyr

    Megafyr

    Joined:
    Oct 29, 2007
    Messages:
    957
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Thanks for the reply guys. I got it right now.