[SOLVED] DestinationIsCrowded prevents movement to new destination

Solution: Okay, I was able to solve it by looking into the Example18_RTS sample provided with beta 4.3.47. For anyone in the future who may run across this issue, here is the solution that worked for me:

// The following code snippets are within a custom input handler class that
// is responsible for listening to user input to set a unit's destination/move
// units around. So this can go wherever you want it to go, just make sure
// you're referencing things properly

//. . .

private IAstarAI _ai;

// . . .

private void Awake() {
    // if this behavior is attached to the same gameobject as your ai script implementing the IAstarAI interface
    _ai = GetComponent<IAstarAI>();
}

// . . .

public void SetDestination(Vector3 position) {
    if (_ai == null || !this) return;
    _ai.destination = position;
    (_ai as AIBase)?.rvoDensityBehavior.ClearDestinationReached();
    _ai.SearchPath();
}

// . . . 

Use the SetDestination() method for setting the unit’s destination.

TL;DR - Using Stop when destination is crowded causes units to not move after reaching their destination and I have to give them a new destination twice, in order for them to start moving again.

Hey all, I’ve just recently started using this asset, and let me just say thank you so much Aron. What a time saver!

I am working on a small multiplayer rts project for fun to refresh my memory on a few things netcode-wise and get familiar with this package.

I noticed when using local avoidance and enabling Stop when destination is crowded, my units will not move again after reaching their destination until I give them a new destination a second time. Or in other words, after the units arrive at their destination, they will not move to a new destination unless it is set more than once. This happens with AIPath and RichAI, doesn’t matter which one you’re using.

For clarity’s sake, here is the order of events and their outcome:

  1. Right-click to give multiple units a destination
  2. All units move to the destination, properly avoiding one another
  3. All units “arrive” at their destination (really they stop because it’s crowded), properly avoiding one another
  4. Right-click somewhere else to give them a new destination (after they have stopped)
  5. Units will not move, however, new destination is properly set, paths are properly calculated and displayed with gizmos
    5.1 NOTE: if right-clicking a second time on the same exact “new destination” spot, they will still not move
    5.2 Sometimes one or two of the units will move to new destination on first try.
  6. Move the mouse a bit and right-click a second/third time in a slightly different position and they move to the new destination.

It should also be noted that while en-route to the destination, changing their destination while they are still moving works as expected. It’s only after they have reached their destination do they refuse to move again unless you set a new destination twice. This also only happens when Stop when destination is crowded is enabled. Disabled, it works fine but I really would like that functionality, otherwise, my purpose for using local avoidance is kinda moot.

3 Likes

Hello! I registered this account in order to thank you for your find. I still have a edge case where one or two in a group of 20 will pause until a path is recalculated, but I only see it only once in maybe 5 playthroughs.

2 Likes