RVO improvements

Hi Aron,
I’ve just bought the pro version and am excited.

I have two questions:

  1. Can I prevent fighting and pressing into obstacles when the AI arrives the target?

  2. RVO doesn’t support rotation to be turned off?

  3. How to stop and pause movement / pathfinding?

Thanks
weyoun

Hi

  1. Usually the best way is to make sure to assign the agents different targets.
    You can take a look at this method call: https://arongranberg.com/astar/docs/class_pathfinding_1_1_path_utilities.php#ad7b708f2886466e46db7dae5dc1ee4e2
    You might also do some other checks like in this thread: Which options of the asset are best for RTS (like Starcraft II)
    There is nothing explicitly built-in for this however.

  2. RVO doesn’t care about rotation at all. It does however make the assumption that the agent can change its velocity to any direction instantaneously. If you are using one of the included movement scripts such as AIPath, then that script has control over movement. I think (not completely sure) that you can disable rotation by setting the rotation speed to 0 and setting the ‘slow when not facing target’ field to false.

  3. Depends on how exactly you want to stop it. Do you want all agents to completely freeze as if time was stopped? Do you want them all to slow down and stop, but be able to continue along their previous paths later? Do you want to do it for all agents? A single agent? There are many different things you might mean by this question.

  1. You’ve posted the same link twice :slight_smile:

  2. Then I would stay with the normal 2D example and improve it with the different target code.

  3. I would like to stop them at the next grid element like in 2D RTS games.

  4. What is an efficient way to update the scene to take notice of moving objects? Currently I am updating it by calling
    void Update()
    {
    AstarPath.active.Scan();
    }
    every frame. But I noticed frame drops and can not imagine it is the best method.

  1. Ah. Sorry about that. I updated my original post.

  2. Ok. So you are saying that you have an agent that is moving and following a path, and now you want to make it stop at the center of the next node it will reach instead of continue to follow the path? You want to prevent it from stopping in between tiles?

  3. Take a look at https://www.arongranberg.com/astar/documentation/dev_4_1_8_94c97625/graphupdates.html
    More specifically I think you will want to look at the DynamicGridObstacle component. That should be the easiest one to use in your case.

1&2. This looks awesome: Which options of the asset are best for RTS (like Starcraft II)
But is the IAstarAI.cs a part of the beta? Cause it is not in my current version.

3: I would like the units to stop at the next grid node right.

4: I saw that before. But that’s too much for a beginner. Thought there would be an easy way :slight_smile:

(edit: editor made 1 and 2 out of 3 and 4 :-/)

1&2. Yes IAstarAI is part of the beta.

  1. Ok. So there is no built in way to do this with the current AI scripts as this is a pretty unusual requirement.
    One simple way is to do this:

    ai.destination = (Vector3)AstarPath.active.GetNearest(ai.steeringTarget).node.position;
    ai.SearchPath();

This will make the AI stop at the node that is closest to the point it is currently moving towards.

  1. The DynamicGridObstacle is very easy to use. You can pretty much just attach it to any object with a collider that moves and it will work out of the box. You can take a look at the example scene called “Example2”.
    There are so many ways one can update a graph, it’s hard to describe it in a concise way in the documentation :confused:

I tried the beta and it’s nice to see that RVO is now more smooth and the AI does not get stuck in the obstacles anymore. Is it possible that the agents do not kick the others around? I want to use it for vehicles and it does not look so nice, if the get pushed away :slight_smile:

Hi

Unfortunately due is due to how the RVO algorithm works. It assumes that for every potential collision, the 2 agents involved will take equal responsibility for it.
What you might be able to do is to increase the priority of the agents when they are standing still or moving slower. This might get you a similar effect.

Is RTS movement really such an unusual requirement? I mean there is enough sourcecode how it’s done, but I’m not deep in the topic of pathfinding. That’s why I paid $100 for it :wink:

OpenRA: www.openra.net
OpenDUNE: https://github.com/OpenDUNE/OpenDUNE
DuneLegacy: http://dunelegacy.sourceforge.net/website/development/sourcecode.html

Thanks
weyoun_9th

RTS movement isn’t really a well defined thing. SC2 does it very differently from SC1 which does it very differently from DUNE which does it very differently from Supreme Commander, etc. RVO comes from academia, but it has been used in many games. The RVO algorithm is however specifically for disc-like agents in continous space (i.e, not grid based) that can change their velocities instantaneously, it is not that well suited for vehicles.
Vehicles is a lot more tricky. I looked at the red alert games, and they seem to do some kind of grid based pathfinding around existing vehicles. Red alert 3 might have done some form of cooperative pathfinding, but I am not sure.
I have been experimenting with cooperative pathfinding (see https://arongranberg.com/2015/06/cooperative-pathfinding-experiments/) however it’s nothing I have included in the package so far.

1 - I’ve tested DynamicGridObstacle but it doesnt seem to work with 2D?

2 - Any news about IAstarAI? When do you think will it be in the stable version?

3 - Any idea to have multiple targets with spawning units? (I am testing multiple targets. Everything works fine unless I make the target a child of an unit. Having problems if I move a Target1 and Target2 isnt moved AILerp moves the unit which is connected to Target2 anyway…)

4 - I would love to create waypoints which are moved one after another. How would you realize that?

Hi

  1. Which version? I’m pretty sure it works in the latest beta, not quite sure if it works in the released version right now, though I think it was a while since I fixed it.

  2. I think I will release it pretty soon. You can pretty much use the beta at this point, it is more stable than the non-beta.

  3. Don’t make the spawned units children of the unit that spawns them. That does not make sense if they are going to move independently.

  4. In the current beta there is a script called ‘Patrol’ which has pretty much this behavior (except it moves back to the start after having reached the last waypoint). You can look at that and extend it.

  1. The “Target” is the child of spawning units, else I dont know how to assign every new unit it’s own Target GameObject?

1,2,4 Thanks. I was waiting for the released version… but if the beta is so good I will use that now.

  1. You can just create a new GameObject, it doesn’t have to be a child object. Or if you use the beta you can just set GetComponent().destination = somePosition directly without having to use new GameObjects. (IAstarAI is an interface which all movement scripts – e.g AIPath, RichAI, AILerp – implement)

Sounds perfect. Thanks

An example mix of 2D and RVO 2D would be cool. units waiting gridbased for eachother and stop at nearest like in good old 2D (rts) games.

I am trying to implement ai.destination but [HelpURL(“http://arongranberg.com/astar/docs/class_pathfinding_1_1_a_i_destination_setter.php”)]
isnt working anymore.

Sorry about that link. It doesn’t work because that class only exists in the beta. You can find the beta docs here: https://www.arongranberg.com/astar/documentation/dev_4_1_8_94c97625/

Note that you don’t need an AIDestinationSetter to set ai.destination. The AIDestinationSetter is just a script that sets ai.destination to the position of a GameObject every frame.
See https://www.arongranberg.com/astar/documentation/dev_4_1_8_94c97625/iastarai.html#destination

Ok, thanks for that. I have changed AIDestinationSetter to
void Update () {
if (target != null && ai != null)
{
ai.destination = (Vector3)AstarPath.active.GetNearest(target.position);
}
but they are still fighting for the target. Anything wrong?

They are still trying to get to the same position, aren’t they?

yes, what am I doing wrong?