• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Fixed Flight Height (ignoring cliffs)

Status
Not open for further replies.
Level 8
Joined
Mar 26, 2009
Messages
301
The title says it all. Is it possible to render a flying unit unaffected by enviromental factors such as cliffs, ground level.. So it will move in air without going up and down when passing through different heighted spots.. Possible?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You have to factor in the terrain z coordinate also.

This is a part of the code in one spell of mine, which makes projectiles to factor in terrain height changes, and the projectiles can collide with hills.

JASS:
// Position of projectile
local location l1 = Location( r1 , r2 )
// Where the projectiles should be moved
local location l2 = Location( r4 , r5 )
// Z offset between locations
local real r7 = GetLocationZ(l2) - GetLocationZ(l1)
// Height change per loop
local real r8 = LoadReal( hash , id , StringHash("height") )
// Final Z offset in relation to terrain height
local real r9 = GetUnitFlyHeight(u) - r7 + r8

If r9 is > 0, then the missile will not collide with a hill and it can be moved to loc2. Otherwise it will collide, and I destroy it.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • Untitled Trigger 023
    • Events
    • Conditions
    • Actions
      • Unit Group - Pick every unit in group and do (Actions)
        • Loop - Actions
          • Set u1 = (Picked unit)
          • Custom script: set udg_i1 = GetHandleId(udg_u1)
          • Set p1 = (Position of u1)
          • Set p2 = (p1 offset by some speed towards some angle degrees)
          • Custom script: set udg_r1 = GetLocationZ(udg_p2) - GetLocationZ(udg_p1)
          • Custom script: set udg_r2 = LoadReal( udg_Hash , udg_i1 , StringHash("height") )
          • Set r3 = (((Current flying height of u1) + r1) - r2)
          • ...
          • Custom script: call RemoveLocation(udg_p1)
          • Custom script: call RemoveLocation(udg_p2)
 
Status
Not open for further replies.
Top