Following Ground Pathing

TheOverWhelm

Member
Reaction score
16
Is there a way to make a unit follow the rules of a ground unit, with like pathing and such but not interfere with the collision of any ground units? 0 collision doesn't work for this case since any nearby unit's collision will be interfering.
The reason I ask is because I want my knockback system to follow the rules of the ground units, AKA not put units ontop of unpathable things (for ground units) and still give them order capabilities.
This is why I used SetUnitX and SetUnitY instead of GUI's MoveInstantly one.
But I can't seem to make it so that the units follow ground unit's laws.
I have tried...
-Checking if a point is Ground Pathable (it doesn't work well, it doesn't detect Destructibles and Doodad's path stuff)
-SetUnitPosition, but that's just Move Unit (Instantly) in GUI so the orders aren't usable (lags a ton of unit isn't paused)
-And I'm currently messing with a Dummy Unit that follows SetUnitPosition and the Units MoveX and MoveY there but the units follow movement orders and they get set outside their collision radius from the Dummy Unit

I also know my code is working perfectly fine (could be a bit more efficient but that's for a later time ^_^)
Suggestions?
 

Dirac

22710180
Reaction score
147
Well i know whats happening here

1.- X/Y ignores pathing, always

2.- Your knockback system uses as a reference the point where the unit was knockbacekd initally instead of the current position of the unit

How to solve?
change the method of your knockback, move the unit X units away from its current position (not the starting knockback position) and use Move instantly instead of X/Y
 

TheOverWhelm

Member
Reaction score
16
1 I know.
The issue is Move Instantly makes the unit unable to give any commands during the Knockback, and if the unit isn't paused during the process of "Can't give orders because they're nulled next MoveInstantly" it lags really badly.
 

Bogrim

y hello thar
Reaction score
154
Create a unit at the point you want to move your unit to, and compare the x and y values of your position and the created unit's location. If they match, the position is walkable. If they don't, the unit will have a different location because the position it was created at wasn't walkable.
 

TheOverWhelm

Member
Reaction score
16
I tried this and it lagged quite bad, having units being created and removed at the same time. In that I did a "set Q = CreateUnit (Peasant)" stuff and checked coordinates, then removed the unit.
I have been trying with doing a "SetUnitPosition" with a dummy unit for the entire system in order to reduce lag (effectively works) but the KBing units then move farther away because there's this unit there.
If you've played a RP map such as SotDRP and had 'nced a unit near another unit with its collision on, you'd notice when the unit with its collision on instantly moves farther away from the 'nced unit.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
I tried this and it lagged quite bad, having units being created and removed at the same time. In that I did a "set Q = CreateUnit (Peasant)" stuff and checked coordinates, then removed the unit.
I have been trying with doing a "SetUnitPosition" with a dummy unit for the entire system in order to reduce lag (effectively works) but the KBing units then move farther away because there's this unit there.
If you've played a RP map such as SotDRP and had 'nced a unit near another unit with its collision on, you'd notice when the unit with its collision on instantly moves farther away from the 'nced unit.
try to add the "Ghost" ability (Rawcode 'Agho') to your dummy unit. it does remove the collision with other units completely.
 

TheOverWhelm

Member
Reaction score
16
try to add the "Ghost" ability (Rawcode 'Agho') to your dummy unit. it does remove the collision with other units completely.

Didn't work.
Going to sleep now, so responses may be a few hours late.
Edit: By Didn't work I mean the same issue without the Ghost.
 

TheOverWhelm

Member
Reaction score
16
Sort of resolve.
I changed the check to check if a spot is buildable, seemed to work. Issue is that means I have to change all the tiles (easy, but slightly annoying) to pathable but I dunno what to do about shallow water.
 

Rushhour

New Member
Reaction score
46
Here a slightly modified version of a script made by Vexorian.

JASS:

library_once IsWalkable initializer Init
globals
//thanks to vexorian once again, modified
    private item it
endglobals

function CheckPathability takes real x, real y returns boolean
    local boolean b=false
    call SetItemVisible(it,true)
    call SetItemPosition(it,x,y)
    if ((Pow(GetItemX(it)-x,2)+Pow(GetItemY(it)-y,2))<=100) then
        set b=true
    endif
    call SetItemVisible(it,false)
    return b
endfunction

private function Init takes nothing returns nothing
    set it=CreateItem('ciri',0.,0.)
    call SetItemVisible(it,false)
endfunction

endlibrary

This checks if a point is walkable by normal units, I use it for my knockback system. Walks perfectly fine. Though you would need to search for the original code if you want to have it 100% save, since this would also count an item as an unwalkable spot (though not units, trees, cliffs,...) Also deep water would be completly 'unwalkable'.
 

TheOverWhelm

Member
Reaction score
16
Effective. I guess items are better checkers then units ^_^, doesn't lag when I create/destroy a lot, I'll change it to a variable at some other point though.
Thanks
[Sorry for long reply]
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top