• 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.

Weird Y Offset With Lightning

Status
Not open for further replies.

Deleted member 219079

D

Deleted member 219079

Lightning.create:
JASS:
        static method create takes real x1, real y1, real z1, real x2, real y2, real z2 returns thistype
            local thistype this = thistype.allocate()
            local timer t = NewTimer()
            local unit dummy = CreateUnit(P_EFFECT, U_DUMMY, x2, y2, 9)
            if UnitAddAbility(dummy, A_FLY) then
                call UnitRemoveAbility(dummy, A_FLY)
            endif
            call SetUnitFlyHeight(dummy, LIGHT_HEIGHT+z2, 0)
            call DestroyEffect(AddSpecialEffectTarget(EF_NODE, dummy, "origin"))
            call UnitApplyTimedLife(dummy, 'BTLF', 2)
            set me = AddLightningEx(LIGHT_CODE, true, x1, y1, LIGHT_HEIGHT+z1, x2, y2, LIGHT_HEIGHT+z2)
            call BJDebugMsg("z1+height: "+R2S(LIGHT_HEIGHT+z1))
            call BJDebugMsg("z2+height: "+R2S(LIGHT_HEIGHT+z2))
            call SetTimerData(t,this)
            call TimerStart(t, LIGHT_TIME, false, function thistype.onExpire)
            set dummy = null
            set t = null
            return this
        endmethod
You can see from the pic that the lightning has a good distance to the caster, why does this happen / how can I fix this?
 

Attachments

  • asd.jpg
    asd.jpg
    381.6 KB · Views: 150
Level 26
Joined
Aug 18, 2009
Messages
4,097
How are we supposed to see the mistake from the extract you presented? We do not know how the coordinates come up nor is it possible to determine if the x/y is off or the z from your 2d pic. Please regard that the z component in lightning functions refers to the world z, not the distance to the terrain surface.
 

Deleted member 219079

D

Deleted member 219079

That would explain it, I'll test it with +GetTerrainHeight() and report here :)

Edit: It worked! Thank you for solution +rep
 
Last edited by a moderator:
Status
Not open for further replies.
Top