• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

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