Acheiving A Smooth Knockback

Frosthowl

TH.net Regular
Reaction score
15
Ok, ive made several knockback spells in the past, but every time the knockedback unit collides with another unit, they seem to jump all around the unit before rolling past the unit. What is the most efficient way to make the unit sliding back not jump around the unit it collides into nor continue on past it? The same thing with doodads as well please.
 

Leazy

You can change this now in User CP.
Reaction score
50
The easiest way would be to turn the collision size off for the unit being knocked back.
 

Frosthowl

TH.net Regular
Reaction score
15
Sorry, I wrote that rather poorly, what I meant is that i want it to get stuck at the unit or doodad it runs into without passing through said unit or doodad.
 

darkbeer

Beer is Good!
Reaction score
84
if turning collision size off doesnt work, youll have to go with a little jass and XY coordinates:

e.g.
is the point with polar offset thing in GUI with an offset of 20, the location is that of the unit sliding and the direction is the facing of the unit.

Code:
Custom script: call SetUnitX(Unit, GetUnitX(Unit) + 20. * Cos(GetUnitFacing(Unit) * bj_DEGTORAD))
Custom script: call SetUnitY(Unit, GetUnitY(Unit) + 20. * Sin(GetUnitFacing(Unit) * bj_DEGTORAD))
 

Frosthowl

TH.net Regular
Reaction score
15
Code:
struct SpellShove
unit c
real ang
real x
real y
integer dist
endstruct

function Trig_Shove_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

function Shove_Actions takes nothing returns nothing
local timer t = GetExpiredTimer()
local SpellShove data = GetTimerStructA(t)

    if data.dist > 0 then
        set data.x = data.x + 10 * Cos(data.ang)
        set data.y = data.y + 10 * Sin(data.ang)
        set data.dist = data.dist - 10
        call SetUnitPosition(data.c, data.x, data.y)
    else
        call data.destroy()
        call ClearTimerStructA (t)
        call PauseTimerBJ(true, t)
        call DestroyTimer (t)
    endif
set t = null
endfunction

function Trig_Shove_Actions takes nothing returns nothing
local SpellShove data = SpellShove.create()
local unit u = GetSpellAbilityUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local timer t = CreateTimer()
set data.c = GetSpellTargetUnit()
set data.x = GetUnitX(data.c)
set data.y = GetUnitY(data.c)
set data.ang = Atan2(data.y - y, data.x - x)
set data.dist = 600

call SetTimerStructA(t, data)
call TimerStart(t, .03, true, function Shove_Actions)
endfunction

//===========================================================================
function InitTrig_Shove takes nothing returns nothing
    set gg_trg_Shove = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shove, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Shove, Condition( function Trig_Shove_Conditions ) )
    call TriggerAddAction( gg_trg_Shove, function Trig_Shove_Actions )
endfunction

When the unit being shoved hits another unit, it spazzes out and jumps around the unit it collided with. Even if i set it to move a smaller amount at a time, the same thing happens.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top