• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

How to do starcraft 2 pathfinding?

4 posts in this topic

I've been trying to figure out how to implement something like the pathfinding in Starcraft 2. I'm not looking for all the sophisticated features like flocking, queueing, etc. In fact I like how in Starcraft 1 the units would interfere with each other. But I do want a path finder better than that used in Starcraft 1.


From the Google searches I've done the various answers have something to do with A* over a navigation mesh and/or dealing with some kind of "visibility graph". But I've gotten somewhat conflicting or unclear answers on what I should do.


One thing I keep encountering has something to do with doing A* over a navmesh. And then use funnel to straighten out the path.


An older post http://www.gamedev.net/topic/597457-pathfinding-in-a-space-based-rts-game/ has an answer that says "Starcraft II uses a constrained Delaunay triangulation of the map terrain and buildings to produce a navmesh; A* with a funnel filter is used to path along this mesh, taking into account unit radii; then local steering and collision avoidance layers are added on top of that"


What exactly are the nodes of A* on navmesh? I don't see how any choice of nodes would allow A* on navmesh with a funnel filter to guarantee the path is optimal. But Starcraft II seems to not have the problem of A* going the "wrong way" around an obstacle because of a "shorter" pre-funnel filtered path.


How does Starcraft 2 pathfinding deal with the fact that the units are discs with a finite radius and not points when dealing with corners? And how does it deal with dynamic obstacles like idle units? Units are discs not polygons so treating them as part of the navmesh shouldn't make sense right? And how does pathfinding figure out that big units won't be able to fit through a far away narrow space. For a new buildings added does Starcraft 2 rebuild a new navmesh?


I'm looking for some gritty detailed explaination and not the generic super high level overviews that I've seen typical in search results. It sort of boggles my mind that there isn't a single source detailed explaination tutorial on the basics of the stuff. There is so much stuff out there I don't know what to look at and what to ignore.


If it matters I've already looked at Amit’s Notes about Path-Finding. I've heard of but not read Computational Geometry: Algorithms and Applications. And a blog post about a AI navigation presentation at GDC 2011 mentioned that Starcraft 2 uses a constrained delaunay triangulation for a navmesh. Although the blog post mentions Boids steering and "horizon analysis".


I really wish that guy ApochiPiQ who I quoted above knows the detailed answers to everything and obsessively answers this question.

Edited by ccherng

Share this post

Link to post
Share on other sites

Well, I am no expert but I actually have pondered this myself and the following are my conclusions:




And how does it deal with dynamic obstacles like idle units?


Well this is easy, and you answer it yourself with 'boid steering' but I will explain that further. So each unit has some kind of inner area of influence and an outer area of influence, see my mspaint picture:




Now one can, using math, get a value of 0.0 - 1.0 of your position between those area of influences! So using this 0.0-1.0 value you can slowly steer the units steering vector away based on how close you are to another units inner area of influence. E.g:




Now buildings can easily mark A* nodes as closed \ open on demand with little performance impact and if A* can't find a way out it just gives back the path up until it deemed the end point impossible to get to.




What exactly are the nodes of A* on navmesh?


Well nodes of A* are generally just a grid representing passable \ not passable terrain and that can be enhanced with a navmesh that basically says all of this is a node and matches an area precisely (or more precise than a grid)...hang on there is an article I read about this a few years ago:




There you go! Have a read of that it should answer the rest of your questions I think. Digest that information and ask more!


Share this post

Link to post
Share on other sites


You could make a grid and in this grid each cell is linked to its neighbours cell,

each cell contains a cost, this cost is the units radius and how far it is from the target cell.


you could even create a second grid of boolean values for building if boolgrid cell ==  true then its  blocked path around it.


and use A*;

here is a good link.


float grid[100][100];//this could be where all objects live to instead of a float use a class structure.

bool blocked[100][100];



Share this post

Link to post
Share on other sites

@ankhd - Grids are memory expensive and don't deliver accurate results when compared to a navigation mesh.




What exactly are the nodes of A* on navmesh?


Let me shed some more light on this question.


The nodes of A* on a navigation mesh are the vertices of the navigation mesh. When searching with A*, you assume the navigation mesh is a waypoint graph, because due to the convexity of each polygon, you know that each node is directly connected to every other node within the polygon, so there's absolutely no difference between a search on a navigation mesh and a search on a waypoint graph.


This article explains it very well.



The only difference between a navigation mesh and a waypoint graph is the vertices of a navigation mesh hold information about an area rather than a single passable point. After the path has been found, the next step is to apply a funnel algorithm to simplify the found nodes into a more direct path.



I recommend reading through the documentation of the two libraries recastnavigation and detour. They are documented on CritterAI's website: http://www.critterai.org

Edited by TheComet

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0