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. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  4. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  5. Units have been turned into heroes in our latest Icon Contest! Vote for the best icon set at the Icon Contest #18 Poll!
    Dismiss Notice
  6. The poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  7. The raddest synthwave tracks were chosen - Check out our Music Contest #12 - Results and congratulate the winners!
    Dismiss Notice
  8. 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] Setting unit Z coordinate

Discussion in 'Triggers & Scripts' started by Gismo359, Apr 23, 2016.

  1. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    771
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    So, I am trying to make a few units orb around a hero but the height must be relative to the hero, so they always remain at around his head level.
    Unfortunately, while doing it I ran into some very weird results, as seen in the attachment.
    There, I try to put them at the exact same Z as the hero, so the problem is much more visible.
    The numbers on the side are the flying heights of the units (go up to 30 while moving, and never go below 0.0010).

    Code (vJASS):
    call SetUnitFacing(udg_Orbs[i], udg_OrbAA[i] + bj_PI/4) // in case these make any difference at all
    call SetUnitPosition(udg_Orbs[i], x, y) // so the unit turns properly without going glitching

    //x and y are the unit's new coordinates
    //mx and my are the hero's coordinates
    //udg_Orbs[i] is the unit in question

    call SetUnitX(udg_Orbs[i], x)
    call SetUnitY(udg_Orbs[i], y)
    set loc = Location(mx, my)
    set mz = GetLocationZ(loc) // Hero has fly height of 0, so not adding it

    call MoveLocation(loc, x, y)

    call SetUnitFlyHeight(udg_Orbs[i], mz - GetLocationZ(loc)/* + height to head level, when I fix it */, 0)
    call BJDebugMsg(R2S(GetUnitFlyHeight(udg_Orbs[i])))
     


    I am pretty sure this became a problem after 1.27, though I may be wrong and just not noticed it before (although it is very obvious).
    What I know for sure, is that the hero's head is around fly height 75, and the 24 fly height units around it go much higher.
    Not only that, but the orb that is seen above him is actually on lower ground.

    What could I be missing? I havent had this happen before, I think it might be a bug in the new patch.
     

    Attached Files:

  2. Emm-A-

    Emm-A-

    Joined:
    Jul 1, 2008
    Messages:
    1,313
    Resources:
    0
    Resources:
    0
    Well, the reason these numbers dont go below 0.0001 or so, is that you cannot move a unit underground, isnt it?

    I just tried it out by

    Code (vJASS):
    call SetUnitFlyHeight( gg_unit_hgry_0000, 250. - GetLocationZ(GetUnitLoc(gg_unit_hgry_0000)), 0. )


    and the unit increases the fly height to more than 300., if the terrain gets lower than 0.

    From this, I can confirm your findings
     
    Last edited: Apr 23, 2016
  3. Meatmuffin

    Meatmuffin

    Joined:
    Jul 25, 2014
    Messages:
    454
    Resources:
    9
    Maps:
    2
    Spells:
    7
    Resources:
    9
    I have gotten myself around negative values with an if condition
    Code (vJASS):
    if z2 > z then
         actions if z2 height is greater than z height
    else
         actions the other way around
    endif
     

    Subtract/add your terrain height based on which level is higher.
     
  4. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    771
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    My problem is that the unit is appearing much higher than it should, and I have no idea why.
    Here is a few more screenshots - in the first one, the difference in the Z of each of the orbs is at maximum 5 (639-643) yet one of them significantly higher than the others (even higher than the hero model).

    The others are when the fly height is exactly 75 at all times - they appear in very different positions. I even tried moving them at the exact XY coordinates of the hero and the distance to the terrain was visibly changing (and it shouldnt be).

    Also, I havent touched model scaling and the cliff leves are the same in all screenshots.
     

    Attached Files:

  5. Anitarf

    Anitarf

    Joined:
    Oct 19, 2015
    Messages:
    286
    Resources:
    0
    Resources:
    0
    If your orbs are using the "Fly" movement type, change it to "Hover" and use the crow form trick to make their flying height changeable.
     
  6. Gismo359

    Gismo359

    Joined:
    Jul 14, 2011
    Messages:
    771
    Resources:
    44
    Packs:
    4
    Maps:
    40
    Resources:
    44
    Oh, I didnt know thats how Fly worked. I thought it was the same as Hover. Problem solved, thanks!
     
  7. Arad MNK

    Arad MNK

    Joined:
    Dec 11, 2014
    Messages:
    1,889
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    You can use Auto-Fly by Nestharus too, as well as TerrainZ by someone I don't remember right now.