Can't get Astar formations working on UCC characters

Cheo

Active member
Hello, I'm trying to move a small group of UCC characters using Astar formations like Circle or V, but can't get correct results - in a test project in a duplicate of the Astar-UCC integration demo scene, the leader doesn't take a single step and the rest of the group moves to their respective positions alongside him, but then stay motionless like the leader. In my current project I can get the whole group walking towards their target but only if Wait to move is ticked off.

Can somebody please try moving a group of ucc characters with an Astar formation ? I'll update this thread in the meantime if I find anything new. Also, I think it might be worth it to make two small integration demo scenes for the Astar formations and movement integrations with UCC and BD, it would at least show whether or not it works !

Edit : for clarification, in both projects the leader has no leader game object variable assigned but is the only one to have a target transform variable, and inversely for the rest of the squad. Judging from experience and the BD formation demo scenes this is apparantely how we're supposed to handle this.
 
The Formations Pack works by setting a destination and then letting the agent do the movement. This is done with the A* Movement ability on the character controller. Can you get the agent moving with a single character from the Movement Pack? If you can do that then you can take the same character setup for the Formation Pack tasks.
 
I know, it should work since a simple Seek task works, but I tried again using the Atlas character from the updated UCC-Astar integration demo scene, and I can only get the followers take their respective spot alongside the leader, but then nobody moves. Here's a video showing the issue :


I forgot to show two important things in the video : setting Wait to move to false changes nothing, and the leader can actually move to the destination if the other characters are deactivated.
 
This is likely related to the Formations Pack not thinking that the agents are in position. You can adjust the Stopping Distance on the Formation Agent in order for the agents to know that they are in position and ready to move.
 
Ok so I tried again, and I don't know why but now setting Wait to move to false does allow for the agent to move towards their destination right away ! However the following character doesn't stop correctly when reaching the destination and has some movement animation and a little bit of jitter, and the group remains stuck if Wait to move it set to true. I also tried setting the Stopping Distance to 0.1 and 0.5 and that changed nothing.


Once again, could you please make a simple demo scene similar to the Astar one ? It would show whether or not the thing works and what values could be used.
 
I haven't tried the Formations Pack with the character controller so there may need to be an integration. I will let you know after I can take a look at it.
 
Thanks. One thing I should have mentioned is that I did get the formation pack working with UCC2 and Astar in this prototype from early 2022, so I was surprised not being able to perform a simple formation task with UCC3.

 
Hello, allow me to bump this thread as well, did anyone get the formation pack working with UCC3 ?
 
Bumping this thread again - I took a look at formation movement with Astar again and it's giving me a headache, in addition to the characters not stopping correctly it looks like having more than 2 characters moving together often prevents the group from moving towards their destination, for example if I have a group of 3 characters often the 2 followers will walk to the leader's side and then stand idly. The NavMeshFormationGroup and IAIAgentFormationGroup scripts don't look very different, so I don't know where the root of the issue is.

I also did not get the Charge task from the Tactical park working with UCC, neither with Astar nor with Unity's Nav Mesh.

Finlly, it is worth insisting on the fact that I got irregular results with Astar formations - they sometimes worked almost completely with a single character not stopping correctly, but it looks like duplicating some working characters for example creates some irregularities, I really can't explain that !

I'll ask this once again, we NEED this issue to be looked at, group pathfinding and formations are too big of a feature to be overlooked, and simple integration scenes for each combination of UCC, BD and pathfinding need to be included as both proof of functioning and examples.
 
Well I'm going to bump this one more time. I took yet another quick look and my guess is that it's something about the abilities, but I'm having a hard time with this. @Justin I know this is the end of the year and that there are other things I've asked about, but please you've got to take a look at this when you can, it's been months, and this really is no niche feature !

It's also worth mentioning that when I made a new quick try with the Nav Mesh ability and tasks, the Wait To Move bool seemed to do nothing and it is necessary to leave the ability start type to automatic. The latter point is perhaps not that much of an issue, but the first one is.

Hope all of this can be adressed soon, once again group pathfinding is an important feature that can't stay broken like that.
 
I currently don't have any updates on this - I'll post about it when I do. It will likely be included in one of the feature releases.
 
Well, I took yet another look at this, and barely made any progress. The triangles from the demo scenes work perfectly, but there really seems to be something wrong with UCC, and not just when using Astar actually, nor V3 - I tried using the Nav Mesh Line formation on UCC characters in a V2 project, and it is possible to get two agents moving at the same time, but the Wait To Move bool does nothing ! Both characters immediately start moving without waiting for the formation to be complete like in the demo scene.

Things are still broken with Astar in V3 too. The only useful thing I've found in the code is this line in AStarAIAgentMovement's Awake :

C#:
m_IAstarAIAgent.canMove = false;

canMove is set to true on many occasions in Astar tasks, so we might need an additional parameter for that if we truly want to keep canMove set to false. But I'm not even sure this is related to the matter of hand, I haven't found the root of the issue.

So I ask yet again that this gets a serious look at, this is long overdue, I'm trying to work on enemy AI at the moment but am seriously limited because of this !
 
So I took yet another look at the nav mesh ability only, and finally made some progress ! I noticed that in Formation Group at around line 410, the leader's formationAgent.speed is set to zero. This does not matter to the Nav Mesh Agent Movement ability which doesn't rely on this value. Instead, here's a simple bandaid fix I found for the moment : just make a simple check like this in the Update override :

C#:
                    if (m_NavMeshAgent.speed != 0)
                    {
                        Vector3 velocity;
                        if (direction.sqrMagnitude > 0 &&
                            ((m_NavMeshAgent.updateRotation && m_RotationOverride == RotationOverrideMode.NoOverride) || m_RotationOverride == RotationOverrideMode.NavMesh))
                        {
                            lookRotation = Quaternion.LookRotation(direction.normalized, m_CharacterLocomotion.Up);
                            // The normalized velocity should be relative to the target rotation.
                            velocity = Quaternion.Inverse(lookRotation) * direction.normalized;
                        }
                        else
                        {
                            velocity = m_CharacterLocomotion.InverseTransformDirection(direction);
                        }
                        // Only normalize if the magnitude is greater than 1. This will allow the character to walk.
                        if (velocity.sqrMagnitude > 1)
                        {
                            velocity.Normalize();
                        }
                        m_InputVector.x = velocity.x;
                        m_InputVector.y = velocity.z;
                    }

Another necessary thing is to comment out or modify this line of code in Formation Group :

C#:
inFormation = formationAgent.RotateTowards(leader.Value.transform.rotation) || leaderMoveStatus != MoveStatus.Wait;

Basically, in the formations demo scene the triangle are rotating in the same direction as their leader, but ucc characters can't do that that simply. So if you just set inFormation to true there, it should help get the task actually started, though not all of the time - it seems that characters can get stuck if they do not share a similar rotation to their leader during the first formation despite this change, and it can also randomly happen when reaching a destination. Changing the target's y value and making it unreachable can also get characters stuck.

One last thing - it seems that the ability can only be used with an Automatic start type at the moment, and unless I missed something the AutoEnable bool doesn't serve its purpose.

That's all I have for the moment, I'll come back to this later tomorrow and take a look at Astar, and maybe make a video. Once again, I keep asking for an actual look at this issue, especially now that I've done a good chunk of this tiring investigation work for you.
 
FINALLY ! I had the time to try with Astar in my own project tonight, and it's finally working, see for yourselves !


The only requirement is to comment out the line I showed in the post above. I think I only got the agents stuck once and that's all, it seems more reliable than Nav Mesh but I haven't tested extensively.

@Justin Please do us a favour and make something about this for the next update now that I've found the root of the issue. You could maybe make the waiting for the rotation optional with a bool, or add an easy way to make ucc characters rotate in the same direction as their leader.
 
Top