Search Unity

RTS movement bug

Discussion in 'Scripting' started by Ziron999, May 28, 2019.

  1. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    I'm sure others have done this.
    If you have all of your agents(via navmeshagents) move to a destination they all keep fighting to get to the center and never calm down. How does starcraft/command and conquer get around this issue?
     
  2. adibichea

    adibichea

    Joined:
    Jul 15, 2015
    Posts:
    73
    Don't know what they use, maybe an advance A* algorithm.
    Here, in Unity you can add in each unit a navmeshobstacle and enable carving.
     
  3. Check out and start to play around with the "Stopping Distance" property.
    https://docs.unity3d.com/Manual/class-NavMeshAgent.html
     
  4. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    Not by using Unity's built-in navmesh system, that's for sure!

    It's very much not appropriate for rts games, as the local avoidance is a bit toss. You'll have to find something else, or roll your own.

    Starcraft 2 has the best local rts navigation I've seen, and it's based on some very clever tricks that would be very hard to hack into Unity's Navmesh (friendly agents passing through each other when not fighting, gliding apart, etc.). Unity's Navmesh also stop performing very well if you've got 50+ agents in close vicinity, and it looks horrible. SC2 allows you to grab 200 dudes in a ball and move them like nothing. It even looks good.


    I seem to remember that Aron Granberg's A* project has some better support for rts style games. If you're rolling your own, there's some good advice in the Game AI Pro books, but that'll take some programming chops.
     
  5. Ziron999

    Ziron999

    Joined:
    Jan 22, 2014
    Posts:
    282
    I actually have 1000 units working with navmesh without any issue. It's just creating formations that i am now working on in a performance based way.