Questions for using A* Pathfinding Project for MMO

This thread needs Aron’s (aron_granberg) response for some of the questions but I am happy to also get feedback from others if they can answer the non-Aron questions.

Insight:
I have built an independent, modular MMO framework to use with any socket engine. I need to create an A* pathfinding module for the framework and was planning to invest a few months building out my own solution.
While doing my research, I came across this pathfinding project and noticed how much effort Aron has put into it as well as how long it has been in development; I also noticed that it comes with source code access.

Queries:

  • Firstly, I am wondering if Aron already has a modular build of the A* Pathfinding Project which is easily adaptable to any collision system and is not reliant on any engine?
  • (Specifically for Aron) If the first question was no, are you planning to do something like this? If so, when and is it something I can get in touch with you privately about?
  • Is there a licensing (or personal) issue with someone porting and adapting the source code to work independently?
  • While I can look at the source code, I am guessing I would likely have to familiarise myself with it and spend quite a bit of time working out how intertwined the source is with Unity (which I will do eventually, especially if this goes unanswered); for this reason, my question is - how easy would it be to adapt and port the source code so that it is not dependent on Unity or a specific collision system (sorry if this is common knowledge or written in tutorials)?

I apologise if some of these questions already have answers on the website or forum. I am still yet to read around properly but decided to write this now in the hopes someone with the information may be able to save me some time before I get back to pathfinding properly (pathfinding is marked on my work schedule for next week).

NOTE:
I am not sure if there is a direct contact email or where else would be best for this question so hopefully I haven’t broken a forum rule or posted under the wrong section.

Hi

There is another user who has recently managed to get it working outside of Unity.
I do not know all the things that were required, but it is possible anyway.

Here is the thread: Using pathfinding outside of Unity I think you will find it interesting.

Thanks Aron, just coincidental someone is wanting to do something similar very recently. The read gave me a good idea of how easy it will all be. From what he has said, he sounds like he is still learning how to code, or at least game development (I haven’t heard of anyone seriously making an MMO without zoning and server clusters), so it sounds like it should not be too difficult to achieve but that there is a bit to go through and change to get it all running smoothly.

I had not realised it was not multi-threaded either, which is something I would want to have so that will take quite a bit of work to make everything thread-safe.

It sounds like you decoupled it from Unity early on, is there a reason you decided to make it dependent on Unity instead of keeping it decoupled for modularity?

Hi

Pathfinding is of course multithreaded. However scanning of recast graphs has not been previously. I’m not sure if I mentioned it in that particular thread, but it is multithreaded now in my dev version.
Also, I’m sure you could ask him nicely and he could share some of the changes that were necessary.

Yeah, MMO games are pretty hard to build… But I’m just a middleware provider, I will not be trying to discourage people from trying to make games :smile:

Actually it has been coupled to Unity most of the time. The early version which was compatible with Photon servers had a bunch of files which were essentially dummy versions of Unity classes. The core pathfinding part is the largest part of the source code, in fact it is relatively small. The largest part is generating the graphs and that requires a bunch of engine specific code (which physics methods to call, methods for finding objects in the world, getting mesh information from objects) and all the scaffolding and utilities around it (using Unity’s component based system, editor code, visualization code etc.).

Please note however that while my package has been used for large worlds. MMO games are on an entirely different scale. There may be unforeseen issues.

If you are wanting to use C++. I have to recommend the excellent open source project “Recast” which Unity is using internally and my package is using a part of it translated to C#. https://github.com/recastnavigation/recastnavigation

Oh awesome, that is great to hear in regards to being multi-threaded.

Haha, I hear you. People can learn as they go anyway, it can just be a long and tiring journey to go through.

Oh okay, fair enough. Dummy classes are a simpler way to go about it rather than re-writing everything so that it is decoupled.
In terms of the graphs, I was worrying about something like that as it may take quite a bit of work to write up my own solution to accurately emulate the intended results; but, I was planning on writing my own independent A* pathfinding from scratch so if I can dive into your code easily then it should be a fraction of the work I would have been putting in.

As I had intended to write my own from scratch, I definitely did not foresee this as an out-of-the-box solution so don’t worry about me not being realistic about my expectations. If there were no issues I would be worried that something nasty had happened, haha; nothing is more unsettling than making large modifications without problems arising.

My plan is to firstly decouple your pathfinding from Unity so it is completely independent, while ensuring everything is optimally multi-threaded; then, I will re-write it to accommodate my MMO framework architecture so that it works with zoning.
The way I have implemented zones is through defining their area of ownership as well as an area of awareness (which consists of overlapping with other zones’ area of ownership) so that they are aware of terrain/objects/etc outside of the ownership zone so that systems like pathfinding, or interaction with objects/terrain/NPCs outside of the current zone, is possible to create the illusion of a seamless world. I plan to customise your project to fit in with how my zones are implemented (which could potentially be a lot of work, depending on how everything is structured, hence my initial questions on how easily the source can be adapted, etc).

As I will likely port the project to C++ (especially for use with Unreal Engine 4 for some of my projects), I should really port to C++ before re-writing it for my MMO framework though so I may do that before re-working for zoning. The zoning module can also be used for seamless singleplayer games (I do love my decoupled modules :D) so it would be backwards for me not to do C++ first to be honest (thinking out loud here).

While I have not taken a proper look at Recast yet, I have heard good things about it. Thanks for the recommendation! Will definitely take a thorough look at it; I don’t doubt already that it will most likely be the solution to go for.

@aron_granberg Is there any ETA on this Threaded version of the recast graph. We are porting our game on console and it would be a huge improvement over the current async/coroutine version you released on beta some times ago.

Thanks,

S.

Hi

@lsalaun
I can send you an internal bleeding edge build if you want.

Hello,

I’d love that!

Thanks,

L.

Ok, I have sent you a PM.
I think it should be a clean upgrade, but do a backup just in case.
There are some minor breaking changes, you can find them in the changelog.cs file (along with all other changes).

Thanks a lot @aron_granberg! I’m going to integrate that right away!
I’ll keep you posted.

L.

1 Like

Omg! This is so fast! Overall the new version cut by 4 the time needed to recast our graph! This is a major improvements and decrease our loading time so much! Thanks an awful lot for this version.

Yet I have a question: It does look like changing the number of thread used by AStar does not impact the behaviour of the recast. Is it possible that the multithreaded recast always use the maximum number of threads ?

Thanks again.

L.

I’m glad you like it :slight_smile:

The recast graph uses the C# thread pool class. It will use the same number of thread as what the pathfinding code would use if the thread setting was set to ‘Automatic High Load’ (which is usually the same as the number of logical cores on the computer).