A* Pathfinding Project

Make RVO Agents to surround a target like RTS


#1

Hi all,

I am using the pro version of A* and investigating on the RVO system. My agents can reach the destination by simply using the RVO, like the RVO demo scene.

However, when more and more agents reaching the destination target, they get stuck together like below (as they agent in the front are in battle, I locked their RVO controller when they are in battle state):

Screenshot_2

What I would expect is to let all the agents to surround the target (like most RTS games), but not stuck at the back…Any advice to solve this issue? Thanks!

By the way, here is my settings of RVO Controller:
Screenshot_1


#2

You would have to manually assign different destinations for each agent.

With some trigonometry you can easily find points around the object you’re trying to attack, and have each agent move to the closest node that hasn’t been taken by another soldier.

Aron currently is working on an RTS demo, you should be able to find it on the download page. Though it’s still in Beta. It might help you with your project though


#3

Hello!

What I can see is that you’d prefer using the grid graph. Do you have any suggestion on existing component that I can utilize from the A* pro project to help in this situation. For example, finding the empty points around the unit?

Thanks! :slight_smile:


#4

The graph type shouldn’t matter

Here is a small piece of code you could use to calculate positions for each agent:

public void CalculatePointsAroundObject(AIBase[] agents, Transform targetTransform, float positionRadius)
        {
            float subAngle = 360f / agents.Length;
            float currentAngle = 0;

            Vector3 currentPos = targetTransform.position;
                
            for (int i = 0; i < agents.Length; i++)
            {
                agents[i].destination = new Vector3(
                    Mathf.Sin(Mathf.Deg2Rad * currentAngle) * positionRadius + currentPos.x,
                    currentPos.y,
                    Mathf.Cos(Mathf.Deg2Rad * currentAngle) * positionRadius + currentPos.z);

                currentAngle += subAngle;
            }
        }

#5

Hi,

Thanks for the script. I will try it later tonight. It does give me some insight on how to surround the unit :grinning:!

And, wish Aaron will publish his official stabilized RTS demo soon!


#6

@derek931026

Since you seemed interested. A new beta version with an updated rts demo is now available.


#7

Hi @aron_granberg,

I am now using the Unity 2019.0.3b7 & A* Pro 4.2.7 for my project. Please refer to the below video for the 2 issues :disappointed_relieved::

Game Objective: To send knight to enemy town hall and destroy it. Knight will go straight to enemy town hall, avoid ally tower, and surround the enemy town hall to attack.

Issue 1: When my knight pass near the ally tower (both of them have RVO controller attached), the knight sometimes have some abnormal behaviour (as you can see at 0:09 - 0:13, the blue line path of knight actually shows that turning left is much easier to get pass the tower than turning right, but the knight intended to turn right, and the movement makes it feel so ‘hard’ to get pass it)

Issue 2: During 0:48 - 1:10 , the new coming knight get jittering at first, and then intended to turn right every time to pass the those Knight with locked RVO (which indeed turning left should be a much shorter and easier path to approach the town hall)

Any suggestions for me on solving these issues? Will be much appreciated for your help :smiley:. Here are my settings for the Knight:
image