Line formations - like in Spring

Discussion in 'Planetary Annihilation General Discussion' started by Davioware, June 28, 2014.

  1. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Would it not be enough to have a "single unit move to x/y/z" api to implement a simple "units spread over this line"?
    Well apart from a way to get a mapping from mouse coordinates to world coordinates that is used while the user draws the line.
    And then the pathfinding needs to be good enough to handle it well.

    I've never actually played zero-k though, so dunno exactly what it can do xD
  2. linike860

    linike860 Uber Alumni

    Messages:
    42
    Likes Received:
    243
    The formation code is almost entirely done on the sim. By this time the mouse coordinates are already gone, as is the camera frustum. The sim must be able to take an arbitrary set of points on the surface of a planet and somehow build a formation from those points, only knowing the order of the points. Any formation modding api would have to be server side first of all, then it would have to be limited in order not to allow someone to tank the server by doing something bad. Running arbitrary code for every single unit is bad, so is running arbitrary code for each point in an arbitrarily long line. It's not just that the api would be hard to set up with something that low level, its that exposing something that low level allows someone to tank the server performance, something we really don't want for our server scripts.
    cdrkf, drz1 and cwarner7264 like this.
  3. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    Sure the sim doesn't know about the camera. I was just thinking what would be required to have a simple UI mod that allows the player to spread his units along a line. For that the UI mods needs to:
    a) convert the mouse coordinates into world coordinates
    b) tell the game to move the units one by one to the world coordinates captured while moving the mouse.

    Though I think that doesn't go as far as what zero-k can do.

    Would this kind of "one move command for every unit" be bad for sim performance or can pathfinding handle it?
  4. linike860

    linike860 Uber Alumni

    Messages:
    42
    Likes Received:
    243
    One move command per unit would more than likely be pretty bad for sim performance. At the very least it would be similar to how area patrol has been. Basically it comes down to the number of goals active at any one time, each goal must construct a flow field from it to the unit using that goal. These flow fields are quite costly, both in memory and cpu, thus the fewer goals we have, the more performant navigation is. Formation behavior allows us to have one goal for a bunch of units and still have them not bunch up at that single point. Having each unit use a separate move command would cause a separate goal for each unit, which can be really bad, especially if the flow field it has to construct is large (like moving to the other side of the planet). Also it undermines one of the main design points of the order system, a one order to many units relationship.
    cdrkf and cwarner7264 like this.
  5. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    So a line move command would need to be somehow handled on the flowfield level, so the units use one flowfield till they are very close to the target area and only then somehow spread the units? I see
  6. linike860

    linike860 Uber Alumni

    Messages:
    42
    Likes Received:
    243
    Yeah, we have all of the agents go to a single goal, but as they get close to eachother (and as long as they share a single move order) they will build groups together and fill out individual slots of a grid located at the end goal. This grid is reformed every time individual sub groups join into a larger group, but the goal and thus flow field, don't change during the move. The grid is the level at which all of the custom formation stuff is done, but that grid requires information that is only available on the server, and it does a bunch of per unit operations to figure out the best place for each unit.
  7. Dementiurge

    Dementiurge Post Master General

    Messages:
    1,094
    Likes Received:
    693
    How does grouping them together end up splitting the units into individual grid slots? I'm confused.

    It's surprising that area patrol is still in, actually.
  8. linike860

    linike860 Uber Alumni

    Messages:
    42
    Likes Received:
    243
    As each sub group gets closer to each other, they combine into bigger subgroups. Each subgroup has a set of slots (the grid) and a formation. The formation decides which slot each unit in the subgroup goes to. The grid gets rebuilt from scratch every time two subgroups combine, this gives them more natural flow movement in their formation.

    Area patrol is getting better slowly. It is still immensely useful, it just provides the worst case scenario for navigation, sadly. I'm working on a fix currently that should make ground unit area patrol much better (both in performance and in gameplay).
    Remy561, destravous and cola_colin like this.
  9. doud

    doud Well-Known Member

    Messages:
    922
    Likes Received:
    568
    Regarding the cost of flowfields, i have noticed that most of the time, when sim is slowing down, the culprit is pathing (well to be honest this only occures when i insanely move 1000 kbots together). Do you think, the pathing code performance can be improved more ? By the way, again, congrats for this incredible stuff you devs have achieved with PA ;)
  10. linike860

    linike860 Uber Alumni

    Messages:
    42
    Likes Received:
    243
    Definitely, and we're working on it. :D
  11. GoodOak

    GoodOak Active Member

    Messages:
    323
    Likes Received:
    244
    This whole thread needs a big like button. Thanks for staying on this stuff - even post "release." I know Uber have said repeatedly that they would, but it's just good to see.
    cdrkf and linike860 like this.

Share This Page