• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Pathing issue

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
So I was working on a charge related spell which turns out fine my testing map.
But in its current state is does not check for pathing, meaning it will keep trying to charge into trees.

I googled around for some ideas and use the following method.


1. decide on position to check
2. move invisible dummy unit with 16 collision size to position
3. compare distance between position and current location of the dummy unit

Which works fine in theory, but it collides with the charging unit instantly.

I googled around some more and noticed a method where you move the charging unit away and THEN check.

I tried it and it seemed to work flawlessly. Except one minor detail, I have an effect attached to my charging unit which follows the unit when it is moved away making it extremely ugly.

Is there any other method? I tried the item method but it did not seem to work for some reason.
 
You can use n unit (to check for any pathability) by using SetUnitX/Y instead of SetUnitPosition (or whatever it is). The reason this works is, SetUnitPosition forces a collision check, while SetUnitX/Y merely MOVES the unit and waits for the next tick to calculate pathing. This means that, right after moving the unit, you can check if it collides TERRAIN/buildings, but unit collision isn't calculated yet.

This is important because it lets you check things that the item method doesn't allow (like water/air pathability).
 
Status
Not open for further replies.
Top