HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to make unit ignore cliff heights?

06-08-2009, 01:43 PM#1
rednek
Hard to explain, but I'll try

So, when flying unit moves above cliff, its flying height will increase
Here's an illustrative image:

[The blue gyrocopter is higher, because there's a cliff under it.]

I want to prevent this from happening
I mean, I want the blue gyrocopter to be on the level of red gyrocopter.

I am making a kind of a Jump Spell, and this cliff-changes doesn't look very good :C

I know it's possible to do so, I saw it somewhere, I just don't know how

Thanks for any answers!
06-08-2009, 02:02 PM#2
moyack
You have to use GetLocationZ and set the flying unit height as the one that it should have less the GetlocationZ value.
06-08-2009, 02:20 PM#3
rednek
Hm? I still don't quite understand [sorry]
If I have unit moving towards cliff, how do I know when it's right above it? And how much should I change it? The cliff heigh is changing smoothly...
Isn't there any other solution?
06-08-2009, 03:53 PM#4
moyack
It doesn't matter, the getlocationZ function will give right values, even in a cliff, because it returns the absolute height of the terrain at the specified location.

This is an example (not tested but it should work)

Collapse JASS:
scope HeightFixer

globals
    private location L = Location(0,0)
    private constant real H = 250. // is the constant fly height
endglobals

function FixHeight takes unit u returns nothing
    local real h
    call MoveLocation(L, GetUnitX(u), GetUnitY(u)
    set h = H - GetLocationZ(L)
    if h < 0 then
        set h = 0.
    endif
    call SetUnitFlyHeight(u, h, 0.)
endfunction

endscope
06-08-2009, 05:46 PM#5
rednek
Aaaaah, I understand now :]
Ye, it's working perfectly, thanks a lot!