• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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