| 05-17-2007, 06:37 PM | #1 |
Well just wondering... how to get terrain heigh ? currently im using a stupid method of getting a unit's real height JASS:function GetUnitZ takes unit u returns real return (GetLocationZ(GetUnitLoc(u))+GetUnitFlyHeight(u)) endfunction any other simple native ? |
| 05-17-2007, 06:51 PM | #2 |
There is no other way to get terrain height. And that leaks a location. |
| 05-17-2007, 07:00 PM | #3 |
yes yes i know... was lazy to type out the full leakless code... anyway here's my full function of GetUnitZ, seriously there is no other easier way ? I hate using locations for some lame reason JASS:function GetUnitZ takes unit u returns real local location l = GetUnitLoc(u) local real z = (GetLocationZ(l)+GetUnitFlyHeight(u)) call RemoveLocation(l) return z endfunction |
| 05-17-2007, 07:02 PM | #4 |
No one likes using locations for it, but there is currently no other option. And just a warning, that function of yours won't return an accurate Z height for flying units. There is a smoothing factor built into the height system which will screw it up. And you will also want to null that location. |
| 05-17-2007, 07:04 PM | #5 |
It would also be faster if you moved a global location to X and Y of the unit instead of creating a new location; creating new handles is slow. |
| 05-17-2007, 07:17 PM | #6 | |
Quote:
grim001 : oh yeah !! thanks for reminding me that, kay now shouden't have any problem now! JASS:globals private location L = Location(0,0) endglobals private function GetUnitZ takes unit u returns real call MoveLocation(L,GetUnitX(u),GetUnitY(u)) return GetLocationZ(L)+GetUnitFlyHeight(u) endfunction |
