A* Pathfinding Project

RTS game pathfinding


Just saw this thread! I was asking about just this previously. I’ll see if I can get the RTS Demo to work.

UPDATE: Sadly that requires a pro license, So I will check it out after I complete my project. I’m pretty sure I’m not allowed to use paid assets for a course project. If I’m wrong about that, expect to see lots of questions about how to get it to work. :slight_smile:


fix the rts branch pls


I will when I get back to my main computer. Unite has been pretty hectic so I haven’t been able to get a lot of work done.



I have tried to replicate the native collection has not been disposed errors, but I have not been able to.
What I have tried to do is to just use the RTS scene and use a script to reload the scene several times, but it doesn’t seem to trigger it. Do you have some steps I could follow to be able to reproduce it?



I’ve been debugging the difference in behavior when the agents are stopping and it seems like it’s due to some bad constants I had in my code. From the point where the agents noticed that the destination was crowded they would wait for more than a second before actually starting to slow down.


Try editing a script, let it recompile and then reload the scene. It didn’t work for me, even in your example scene. I don’t see why it wouldn’t work as when you reload the scene everything should get destroyed?
Anyways, I think these things make big difference once you get to the polish stage of the game, because you want to be able to iterate on things fast.


Ah. That did indeed trigger a bug. Every movement script would get their Update method called one more time per frame every time you recompiled and reloaded the scene that way. So the unit would move faster and use more CPU. I did not see any native array leaks though.
I have fixed this in my dev version now.


Well if you got that and the local avoidance working, then can you update the rts branch? I feel like the rts branch has been in pretty much zero day condition for months.


Yeah, that’s what I’ve been working on for the last week :stuck_out_tongue:
I’ve been trying to get a good and stable behavior when moving groups of units and I’m pretty happy with the result right now. I still need to fix a few bugs before I can push out the beta, but it will likely go up within a week.


Good to hear.
By the way what kind of collider setup the RichAI supports?
I’ve been using a capsule collider attached to the same gameobject up until now, but I’ve had this issue where bigger creatures can climb on smaller creatures because I’m still using physics. I was thinking a interesting fix to this problem would be using a cylinder shaped mesh collider parented to the RichAI/rigidbody.
I tried this and it seemed to work mostly fine, but the AI never seemed to reach it’s destination.


I’m just curious is this worth using for an rts style project currently?

I’ve been trying to find a good system where game objects can automatically path around other game objects, but I have not found a way yet.

Is there a way to test this without buying the PRO version?

I just want to be run some more practical tests before I commit to buying it, there also doesn’t seem to be any refund policies.


Hi everyone.

The new beta (4.3.6) is now up. Sorry for taking such a long time to release it. I have been plagued by soo many last minute bugs. I switched some components to use a custom gizmo system and it turns out that gizmo drawing has a ridiculous number of edge cases that one has to get right. I also switched local avoidance algorithm from RVO to ORCA and I had to fine tune it to get a more similar behavior.

The new version has some improved formation code for the RTS demo and the agents stop more reliably. The exception may be when you only have two agents that want to reach the same point in which case one of them sometimes sometimes fails to stop. I know how to fix that case though, I just thought I should push the beta out sooner rather than later.
Performance for local avoidance has also been increased.

The RichAI script supports:

  • No collider/rigidbody (recommended for highest performance)
  • Using a CharacterController
  • Using a rigidbody + Collider
  • Using a rigidbody2D + 2D collider

That would be really bad for performance. Mesh colliders are really slow. A better solution is to rely on local avoidance for collisions and change your project’s physics settings so that agents do not collide with each other (and/or change your agent’s ground raycast mask to exclude the agent layer).

You can definitely do that, but it depends on what kind of rts you want. RTS games have wildly different requirements. Some RTS games work very well with the features that this package has and some would require a lot more features.

This particular demo is only in the pro version (or the beta). However you can try out the free version of the package which should allow you to test most things.


I ran into some issues with updating and kind of figured its better to ask you about it.

Firstfully when just dragging the updating the asset left two “Draw” classes hanging around.

I figured the solution to this was to delete the one that wasn’t static, and that seemed to fix it.
However that wasn’t the end of it. After that I got a bunch of errors like this that I couldn’t figure out

Infact, even importing the asset to an empty project didn’t help.

Do you have any ideas on how to get it working?


Ah. Crap. UnityPackage annoyances again.
So UnityPackages do not support deleting files. In this case I have deleted the original Draw.cs script and made a new one with the same name in another place. However when upgrading unity will keep the original Draw.cs script that I deleted. The correct solution is to delete it in your project. I will publish an update that fixes this.

The second group of errors seem to be because you have a too old version of Unity. The API that I use is pretty recent.


Which unity version do you recommend?


I’m on 2019.3.0b7. I think the high performance mesh API was introduced in one of the more recent 2019.3 betas.


Hi @aron_granberg,

I have downloaded the Unity 2019.3.0b7 and imported the latest A* Pro 4.3.7 into it. When I opened the RTS demo scene, error occurs like below:



I could not replicate that, however I did see some other strange issues. They were resolved after making unity reimport all assets though (so it was just some unity issue).


It’s working now for me.

How do I know if RVO is moving a character (like in the video) so I can hook up an animation to it?


There are several properties on the movement scripts (e.g. AIPath/RichAI) that you can use:

  • velocity Actual velocity that the agent is moving with. In world units per second.
  • desiredVelocity Velocity that this agent wants to move with. Includes gravity and local avoidance if applicable. In world units per second.
  • desiredVelocityWithoutLocalAvoidance Velocity that this agent wants to move with before taking local avoidance into account.