• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Pathing distance

Status
Not open for further replies.
Level 9
Joined
Dec 21, 2006
Messages
490
hi

i am working on a TD and i want to show the length of the maze for every player .The distance is the number of fields between the points. luckily sc2 has a function which calculates the pathing distance between 2 points, BUT it calculates wrong!!! everything is correct if no building/unit is in the path. It doesn't fail calculating all the time, it always depends where the building is and sc2 units seem not to move the shortest way all the time. does any1 have an idea as an explanation?
No building: distance is 11

with building(footprint 1x1): distance is 21
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
This is due to the pathing algorthim they use. Why, I do not know but I can tell you that it uses some form of mesh to navigate. In the editor you can see this pathing mesh and some of the shapes will translate to unit movemement patters very well inagme.

Do a simple test seeing if a unit with 1 speed (1 unit per second) and instant acceleration takes the same time as the distance that native reports to cross the distance you passed it to measure. If there are any deviations in results then it must use a different algorthim from the one units use to move.

Try with more complex maze patterns, as the spaces get tighter the pathing may become more precisice.
 
Level 9
Joined
Dec 21, 2006
Messages
490
more complex maze patterns result in too high values(about 30%). but your idea to send a unit could be a way to calculate the distance more precisely. but if the maze becomes huge i couldn't calculate it in responsible time anymore.
maybe i could send a test unit every wave to check if the calculated distance is correct.
but this does't work for continual updates :( ......
 
Level 9
Joined
Dec 21, 2006
Messages
490
it's important because i have towers that deal damage based on the distance passed. this distance is calculated the same way.
i was wrong. the distance is about 10% wrong most of the time.
used a unit with ms 10, save the mission time on custom value and subtract it from the current mission time at the goal.
but as you can see on the pictures sometimes it is way too much. this one building should affect the distance by MAX 3 ( should be something between 1 and 2)
 
Status
Not open for further replies.
Top