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

Smooth JASS slides?

Status
Not open for further replies.
Level 4
Joined
Jun 7, 2008
Messages
37
Tried making a sliding trigger and the result was pretty lol, can anybody see why?

JASS:
function Trig_Slide2_Actions takes nothing returns nothing
local real x1 = GetUnitX(udg_Pusher[2])
local real y1 = GetUnitY(udg_Pusher[2])
local real angle = GetUnitFacing(udg_Pusher[2])
    
    call SetUnitX(udg_Pusher[2], x1 + udg_Spd[2] * Cos(angle))
    call SetUnitY(udg_Pusher[2], y1 + udg_Spd[2] * Sin(angle))

endfunction



//===========================================================================
function InitTrig_Slide2 takes nothing returns nothing
    set gg_trg_Slide2 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Slide2, 0.02 )
    call TriggerAddAction( gg_trg_Slide2, function Trig_Slide2_Actions )
endfunction
 
Level 4
Joined
Jun 7, 2008
Messages
37
Tried doing so, the unit now slides properly but often ends up moving in circles :x

JASS:
function Trig_Slide2_Actions takes nothing returns nothing
local real x1 = GetUnitX(udg_Pusher[2])
local real y1 = GetUnitY(udg_Pusher[2])
local real angle = GetUnitFacing(udg_Pusher[2])
    
    call SetUnitX(udg_Pusher[2], x1 + udg_Spd[2] * Cos(angle * bj_DEGTORAD))
    call SetUnitY(udg_Pusher[2], y1 + udg_Spd[2] * Sin(angle * bj_DEGTORAD))

endfunction



//===========================================================================
function InitTrig_Slide2 takes nothing returns nothing
    set gg_trg_Slide2 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Slide2, 0.02 )
    call TriggerAddAction( gg_trg_Slide2, function Trig_Slide2_Actions )
endfunction
 
Status
Not open for further replies.
Top