HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Angle Function returning null?

01-30-2008, 01:10 PM#1
Castlemaster
I'm using coordinates to get the angle of two units to use in a knockback system. Every time the unit gets knocked backed, he moves at 0 degrees (east) regardless. Here is the trigger
Collapse JASS:
function Trig_Brutal_Slam_Actions takes nothing returns nothing
    local real xcaster = GetUnitX(GetTriggerUnit())
    local real ycaster = GetUnitY(GetTriggerUnit())
    local real xtarget = GetUnitX(GetSpellTargetUnit())
    local real ytarget = GetUnitY(GetSpellTargetUnit())
    local real angle = Atan2(ytarget-ycaster,xtarget-xcaster)
    call KnockbackFunctions_KBUnit(GetSpellTargetUnit(),angle,20,0.35,0.05,true,true)
endfunction
I'm not sure why the math isn't working. Any ideas?

Thanks ahead of time.
01-30-2008, 03:10 PM#2
PipeDream
Probably your knockback code expects degrees when Atan2 returns radians.

In general the thing to do when posting this sort of question is to put debug messages on as much as possible. In this case since you're wondering if the math is right, post the inputs (xtarget,ytarget,xcaster,ycaster) and the outputs (angle) and any intermediate values (none, in this case).

Anyway, if adding RadToDeg() doesn't fix it, post KnockbackFunctions_KBUnit.