• 🏆 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] Setting unit Z coordinate

Status
Not open for further replies.
Level 19
Joined
Jul 14, 2011
Messages
875
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).

JASS:
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.
 

Attachments

  • WC3ScrnShot_042316_210120_04.jpg
    WC3ScrnShot_042316_210120_04.jpg
    1 MB · Views: 150
Level 14
Joined
Jul 1, 2008
Messages
1,314
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

JASS:
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:
Level 19
Joined
Jul 14, 2011
Messages
875
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.
 

Attachments

  • WC3ScrnShot_042416_000927_01.jpg
    WC3ScrnShot_042416_000927_01.jpg
    945.4 KB · Views: 106
  • WC3ScrnShot_042416_002133_02.jpg
    WC3ScrnShot_042416_002133_02.jpg
    1,010.3 KB · Views: 86
  • WC3ScrnShot_042416_002240_06.jpg
    WC3ScrnShot_042416_002240_06.jpg
    1 MB · Views: 83
  • WC3ScrnShot_042416_002243_07.jpg
    WC3ScrnShot_042416_002243_07.jpg
    1 MB · Views: 100
Level 7
Joined
Oct 19, 2015
Messages
286
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.
 
Status
Not open for further replies.
Top