Locking Flying heights

envenger

Active Member
Reaction score
3
How do i lock the flying height of a flying unit to a constant value?

In my case there is a projectile rotating around a unit. I want that projectile to have the same height as the unit and not go down and rise up when there are cliffs. How do i do that?

I tried setting the Flying height of the projectile to same z value of the unit around which it rotates but, it doesn't work...

here udg_rot = rotating projectle
udg_rotor = unit around which it rotates.

JASS:

function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
    local location loc = GetUnitLoc(udg_rotor)
    local real z = GetLocationZ(loc)
    local real x1 = (CosBJ(udg_angle)*200)
    local real y1 = (SinBJ(udg_angle)*200)
    local real x2 = GetLocationX(GetUnitLoc(udg_rotor))
    local real y2 = GetLocationY(GetUnitLoc(udg_rotor))
    call SetUnitFlyHeight(udg_rot, z, 999)
    call SetUnitX(udg_rot, (x2-x1))
    call SetUnitY(udg_rot, (y2-y1))
    set udg_angle = ( udg_angle + 10.00 )
        if ( udg_angle >= 360.00 ) then
        set udg_angle = ( udg_angle - 360.00 )
        endif
    call RemoveLocation(loc)
    set loc = null
    call RemoveLocation(loc)
    set loc = null
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002_Copy takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002_Copy = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_002_Copy, 0.05)
    call TriggerAddAction( gg_trg_Untitled_Trigger_002_Copy, function Trig_Untitled_Trigger_002_Actions )
endfunction
 

Attachments

  • rot2.w3x
    18.3 KB · Views: 153

Accname

2D-Graphics enthusiast
Reaction score
1,462
An option would be to save the initial Z value of the rotating unit when it is created and then periodically adjusting the flying height of the unit to make its current Z value + new flying height match the original Z value + initial flying height.
In case you didnt know already, the Z value of a unit can be obtained with by getting the Z value of the units position.
Code:
GetLocationZ(GetUnitPosition(...))
 

envenger

Active Member
Reaction score
3
I too tried that. It didn't work then tried this...
This also didn't work.. Can you make a test map?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top