🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Question about simple pathfinding for units with varying sizes.

Started by
2 comments, last by Ray J 3 years, 7 months ago

Hello!

I am asking for help with terms, definitions and literature.
There is a flat 2D surface where units exist. Units vary in their bounding circle radius. They can travel around when issued an order.
I made a custom “pathfinding” algorithm - on collision unit walks 45 degrees of collidable object and resumes his movements toward target location. Whenever it hits something again it repeats the same dance.

It's not a viable solution. I looked into my old A* experiments, but it was a turn based thingy with single cell fields. Thus “grid” layout was a viable solution back then.

Is there a way to adapt A* to different sized units? What's passable for small unit may not be passable for a big one.
In grid example what if one unit took up space of four nodes. How do you calculate movement then.

Checked some guides online for “Navmesh” and “A*”, yet everything is lines and points, no tangible moving objects with actual movement issues.

Any responses/advices would be appreciated. At this point I do not know what I am looking for and thus drown in google search results.

Advertisement

You should have a graph with sparse nodes near obstacle corners and different costs for each edge because node distances vary.
To represent the fact that some large units cannot pass through narrow gaps, the graph edges crossing the gaps can have a movement cost that depends on unit type, infinity above a certain size threshold (or also increased if the passage is a tight fit).

Another probably necessary adjustment: the actual position of the navigation node near a certain corner should be adjusted by unit size (a person and a tank, both represented as a point at their center, would turn the same corner respectively 0.5 to 0.7 and 2 to 3 meters from the wall).

Omae Wa Mou Shindeiru

Thank you for the response!

I was thinking about node weights, one thing i don't like is idea of “node weight recalculation”.

Lets say I have this row of cells, where . means “can pass” and x means the opposite.
x---x
Weights would be as follows
∞232∞

But as soon as there would be an unit in between, lets say “O”
x-O-x
It would change to
∞1∞1∞

Would recalculating entire weight matrix be efficient?
Or am I misinterpreting your idea?

This topic is closed to new replies.

Advertisement