A* Pathfinding Project

RTS game pathfinding


The burst mode doesn’t support obstacles?


I was using Funnel Modifier component and it had a strange effect of making the pathfinding ridiculously expensive.


Is it the funnel modifier you are profiling in that screenshot?
Note that the RichAI component doesn’t need the funnel modifier and will not use the result of it. It already has its own internal funnel modifier which is more optimized for that use case.


Yeah. I figured as much.
But how about the obstacles? Are they not supported?


No, they are not supported yet. It’s a bit tricky to implement them with burst, so I pushed out the RVO burst update before they were completed.


You plan to implement them however?
How long do you think it will take you to implement them?



I do plan to implement it, however I will not have time in the near future. I’ll be away for a little more than a month from Friday.


Having the AI selected in playmode throws NotImplementedException.


also how to avoid this


Hey, currently there is no formation system in the RTS demo.
You can either use RVO to have the agents avoid one another.

Or write some custom code for all the agents to find their own destination,
linking a response from Aron here from a similar question:



Sorry for the late answer. I am currently traveling and I lost my laptop on a flight, so I haven’t been able to work for a while.

Oops. Indeed it does. You can safely ignore it though. I think the inspector should still be usable and the exception should not cause any problems other than being annoying.

Do you have the “Automatically Stop When Destination is Crowded” option enabled on the AIPath script?

Something else that is very helpful is to pick individual destinations for every agent. You can do this with: https://arongranberg.com/astar/documentation/dev_4_3_5_58efaa48/pathutilities.html#GetPointsAroundPointWorld (I really should add an example for it though).

Considering to buy, but have few questions!

Strangest thing is that I had this working a whole lot better when I was using RTS beta version 4.2.8.
I did not write any code for this kind behaviour and was just following your examples.
This is a clip of when I was still using the 4.2.8, and you can see its working a lot better

My only real issue with the 4.2.8 were some performance issues (which do seem fixed now). To be honest, I really didn’t expect the upgrade to 4.3.4 to be so drastic. Like with deleted components and all.

I tried tinkering with the RVO to see if it has any effect, but I think it just made it more crazier.

Looking at your RTS example closer, I think you’re doing your self a bit of a disfavor by using circles, because you cannot see their rotations very well. After adding some models details to the RTSUnit prefab, I think it’s pretty clear that their rotations are pretty frantic, even in the example.

Here’s the configuration I’m using


Strange thing occurs when you hotreload scripts in playmode. The pathfinding starts to be super expensive. This is particularly annoying because our game supports hotreloading.
This bug appeared after upgrading to the 4.3.4, which uses burst. Maybe you’re now somehow storing data staticly, which doesn’t get cleared up on OnDisable.
I find this to be bit troubling, because it might also happening when reloading scenes?


I actually get this error when reloading scenes after hot reload.




Yeah, there might still be some bugs in the Burst version of RVO that causes different behavior. I will take a look to see if I can replicate what you are seeing.

Also, yes, I should implement some filtering for the rotations. When using RVO they very easily become very jittery.

The pathfinding system does in general not support hot reloading since so much state is in classes that unity cannot serialize at all. I’m not sure how you managed to support hot reloading in the first place :stuck_out_tongue:. I don’t think I am storing any data statically. I should definitely fix the “not disposed” errors though. They really look like bugs.

I am away on a holiday now, but I will have a look at it when I get back.


Yeah by hot reloading,I mean OnDisable I create save with json of meaningful game progress. Like unit commands, positioning, whatnot. Then I unload all the scenes (including the pathfinding), reload them and then apply the save.
This worked with old RTS pathfinding version, not the new one.

Yeah you did mention it. I’m pleasantly suprised if you have a chance of look at these things in a month.


Aah. I see.
That definitely sounds like a bug. I will try to replicate it when I get back.


Are you back in action? :sweat_smile:


Sort of. I’m currently at Unite in Copenhagen :slight_smile: