DoN's 3D-Pathfinding / Flying-AI system (with full source!)

I think an octree version would work quite well - should have similar/same performance characteristics for accessing neighbors and the like, with the added benefit of making longer queries faster (since you can reject things based on the highest octree level with the largest volumes).

In any case, awesome system! Thanks a ton :smiley: I am going to use this for the dragons in my game.

@MatzeOGH, @n00854180t - Great! It would make me really happy to see other games use this system.

Let me know if you face any setup issues.

@sivan - thanks, I hope you find it useful. I went through the same route, before I made it a plugin, this was deeply coupled with my own gameā€™s classes and I had to refactor, rename and eliminate unwanted dependencies to make it a separate plugin module. Making the plugin itself was easier than Iā€™d expected, I just used the UObject plugin under Engine\Plugins\Developer\UObjectPlugin as a template and that had me covered for the most part.

Oh my gosh ā€¦ is this real ??? I want it. I used to create cheated paths (precalculated) for the AI when was need it to avoid obstacles but this ā€¦ I need to test it. Thank you! One question: is the pawn aware of itĀ“s neighbours?

Not yet Iā€™m afraid - not formally at least. You could override AddMovementInput for your pawn or implement my AddMovementInputCustom interface (either of which the ā€œFlyToā€ node will use) with your own neighbor avoidance logic and depending on how complex your paths are this might be a viable strategy.

Another option is to use the dynamic collision repathing that I have for regular meshes (dynamic obstacles) for the neighbor pawns (by adding ā€œPawnā€ to ā€œObstacle Query Channelsā€ in the manager) but there are some messy complications with this:

  1. It would recalculate paths each time an obstacle occupies it, which is great for regular obstacles but not very efficient for neighbors whoā€™re travelling along a similar path as you (because of potentially frequent recalculations of the entire query).

  2. The system requires both pathfinding origin and destination to be in empty space and if not, it will reject the query. Now if we add ā€œPawnā€ as a collision object type and your neighbor has reached the goal before you (thus occupying space around the goal) then your pathfinding query will simply fail with a message that the goal is invalid and cannot be reached!

In the sample project the bots often merge into each other because of lack of neighbor avoidance and also because their pawn collision is set to only overlap pawns instead of blocking them.

@ : thanks for the hints! I try to design my stuff to be game designer friendly, so I use e.g. data assets created from csv files for my RTS group formations (and other little blueprints derived from my C++ classes), but I think at the moment content in plugins is not supported, thus probably shipping the plugin with a sample project - as you did - is the best to show how to use a it.

I salute you, sir.
You are the epitome of human generosity.

Is it posible to trigger a second (to nth) path querry that doesnĀ“t intersect with that which calculated before?

Lol not reallyā€¦ After years of benefiting from the system in the form of free open source software, free wikis, free tutorials, guides and forum support from so many people, not just in Unreal, but everywhere, you start to feel guilty that you havenā€™t given back anything to the system from which you took so much. If this plugin is used successfully by other games I would feel some relief in knowing that Iā€™ve hopefully given something back.

Interesting idea. Just try modifying ADonNavigationManager::CanNavigateByCollisionProfile from this:


if (!CanNavigate(Volume))
		return false;


to


if (!CanNavigate(Volume) || Volume->DynamicCollisionNotifyees.Num())
		return false;


ā€¦this might work. We are leveraging the fact that any active path solution will leave a trail of dynamic collision notifyees on the voxels.

Try it out if you need it, I wonā€™t get the time to test this myself any time soon and Iā€™m also wary of implementing this as a formal solution because itā€™s not very across usecases.

Eg: what happens if 10 bots need to travel through a narrow crevice where thereā€™s only room for one bot to squeeze through! So if I implement this at the plugin level, all possible usecases need to be understood, performance profiled, tested, etc. Also, the ā€œFly Toā€ node may be a better candidate for housing a full-blown neighbor avoidance solution as locomotion is its primary duty.

==

Neighbor Avoidance and Octree voxel solution (for supporting larger maps) are long-term features I would love to support some day, but expect at least 4-6 months before I can revisit this!

Iā€™ll release bugfixes occasionally whenever I find them in my own game (which uses this plugin), but for now I need to focus on my personal project and canā€™t commit to new features. The source code is there for people to implement anything they like though! :slight_smile:

v1.1 released

v1.1 contains a major bugfix, make sure you download v1.1 of both plugin and samples if you plan to use this for your game.

Bugfix MSPaint-ed :smiley:

Imagine a flying creature landing on a hard surface (eg: for resting) and then flying away. Because it squats on a red voxel, the system starts pathfinding from the closest green voxel instead (whose center becomes the ā€œeffective originā€). This bugfix ensures that the pawn travels to the effective origin first instead of directly traveling to the next segment (and thus bumping into something on the way!)

c928d8c9a5e1d7a022799306a465450ccf96eb9e.jpeg

I understand that but my case is slightly different than this: a scene level with various obstacles (debris) in a open space and some bots trying to get to a some goals (distributed to each bot, by an AI, depending on the number of bots). WeĀ“re talking about dog fighting (Iā€™ve just put it in a more complicated way :D) I also understand your position in giving the most cleaner solution so that every one could change it to itĀ“s needs and I am 100% with you!
I will like to bother you with one more question: is it possible to have more DON managers in one scene and if so can you pass from one manager to the other?

Thank you for your time.

Edit:
By the way, I watched the DoN The Nature Game ā€“ 30 minute gameplay video! and itĀ“s amazing! And the Vivaldi is the best choice that could accompany your game presentation. I wish you make this nature sim as perfect as possible. The work youā€™ve done is amazing.

Self-contained managers should work with a small fix for ā€œFly Toā€ node to smartly lookup the right manager for a pawn instead of blindly using the first one (thatā€™s how it works now). Iā€™ll look into this in a week or two, should be an easy fix that will deliver great value. For people whoā€™re using direct API calls instead of the ā€œFly Toā€ node you can just tell the API which manager to use yourself.

Again, each manager is self-contained; a pawn in one navigation zone can only pathfind within that zone. Inter-zone/Inter-Manager navigation could be a nice strategy to support large maps so I might investigate that mid-term. The Octree voxel approach suggested by others is probably a better long-term investment but it has ā€œGiant time-sink, Developer beware!ā€ written all over it :slight_smile: so Iā€™ll instead try to support multiple zones for now.

Thanks a lot for checking out my game! I hope to make it an all-encompassing Nature Sim and as long as I can sustain development Iā€™ll keep inching slowly towards that goal.

Steam Greenlight was supposed to happen last month but releasing this plugin took so much more energy than I expected that I couldnā€™t work on the game for almost a month at that time.

Vivaldiā€™s music fuels both development and the promos! There is little doubt in my mind that some 300 years ago the inspiration for his Four Seasons Music draws from the same fountain that Iā€™m tapping into today. Now whether my game ends up at least a wee bit as good as Vivaldiā€™s compositions, only time will tell :wink:

Thank you for great work! :slight_smile:

What version of engine you are using?

I tried to package your sample project and run but Iā€™ve got a error that engine canā€™t find plugin module.
I tried this on 4.10.4

Iā€™m assuming you are using different version, that why it doesnā€™t work.

Are you using the latest version of the sample project - v1.1? The previous version had an issue with packaging that was fixed.

I just tested the latest version lying in my comp and it packaged and ran fine; Iā€™m using 4.10.4 too.

Yes, I downloaded this yesterday.

I had to disable substance plugin to run, because I donā€™t have it.
First packaging failed because assets had too long names - fixed that.
Then I packaged 64 bit build for windows - build successfull.

When I try to launch packaged game, I recieve this message:

error.jpg

When Iā€™m launching from standalone game or pie it works.

Can someone whoā€™s also downloaded v1.1 confirm what @hamsterPL is seeing please?

That would be really helpful to narrow down the issue as Iā€™m not able to reproduce it :frowning:

Try this workaround:

  1. Open the project, choose File -> ā€œNew C++ classā€, create any dummy class
  2. Restart the editor.
  3. Try packaging again.

This workaround has been suggested in the forums for Blueprint-only projects that need to use C++ plugins. Maybe it works for me because I have Visual Studio installed, really not sure.

Another thing - are you packing with build configuration of ā€œDevelopmentā€ or ā€œShippingā€?

Both work for me, although shipping needs a workaround described in this answer hub post (without which it throws a ā€œfailed to open descriptor fileā€ error).

Hmmā€¦Iā€™m not using anything substance related in this project at all! Thatā€™s really odd.

Did it tell you which assets were problematic? None of the Epic content in the project (eg: the bots) seem to use the Susbtance plugin either. The Substance plugin is free in any case, but still Iā€™m not sure why the project seems to need it.

I will try that today. Thanks.

I have visual studio 2015 installed.

Sorry, I forgot to mention - I packed with shipping

I didnā€™t know that. Iā€™ll try, thanks.

Not really, but I assume itā€™s T_MacroVariation. When Iā€™m unpacking your zip file I have this error and canā€™t copy this file:

copy error.jpg

And when I launch editor I got load errors, probably because this asset

Oh yeah, that file developed a CRC issue while I uploaded it, just a file corruption issue totally unrelated to Substance plugin.

I fixed that some time after your initial post by re-uploading v1.1 again. If you have the bandwidth to spare grab the latest upload (itā€™s still called v1.1).

BTW the shipping workaround in the answer hub post can be very hard to find (itā€™s a long thread) so Iā€™ll just paraphrase it here:

  1. Go to WindowsNoEditor\DonNavigationSamples\Binaries\Win64
  2. Change DonNavigationSamples-Win64-Shipping.exe (or 32-bit equivalent) to DonNavigationSamples.exe.
  3. Use that exe for launching instead of the exe under WindowsNoEditor (which will no longer work after applying this fix)

This workaround is not for the plugin load issue though; for that, the ā€œAdd C++ classā€ workaround is the the best bet we have for now so try that first.

Still dontā€™t work :confused:

I tried to create dummy class couple times and compile failed. I recieved following error

failed to compile module.jpg

Then I opened project in visual studio and hit ā€œbuildā€. And compiled failed too. Hereā€™s error list

0ee7484b12c0abf88bc6f90bcf1c0658bf2acb13.jpeg

Ah! If adding a simple dummy class isnā€™t working then it makes me suspect environment issues unrelated to the project.

Can you post the ā€œOutputā€ logs of Visual Studio instead of the error list? For Unreal projects Visual Studioā€™s error list is not usually accurate, the compilation output from the Unreal Build Tool is what weā€™re really interested in here.

In the meantime, if someone else can try packaging and tell us how it goes that would really help! I think most people have the old v1 version (where packaging definitely wonā€™t work) so if anyone wants to give it a try make sure you download the latest version v1.1 first.

I downloaded the sample project from scratch, tested packaging and it just works for me (even without the C++ class workaround) so Iā€™m beginning to suspect this is more environment related.

Output log:


1>------ Build started: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
2>------ Build started: Project: DonNavigationSamples, Configuration: Development_Editor x64 ------
2>  [1/15] Compile DonNavigationSamples.generated.cpp
2>  [2/15] Compile MyClass.cpp
2>  [3/15] Compile Actor_Class.cpp
2>  Actor_Class.cpp
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(16): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(17): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(18): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(29): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(40): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(52): error C2007: #define syntax
2>dbsbuild : error : aborting build on error (2)
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(62): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(63): error C2007: #define syntax
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Intermediate\Build\Win64\UE4Editor\Inc\DonNavigationSamples\Actor_Class.generated.h(73): error C2007: #define syntax
2>c:\users\matuszczyk.matuszczyk-pc\documents\unreal projects\3d_navmesh\source\donnavigationsamples\Actor_Class.h(8): error C2059: syntax error: 'user-defined literal'
2>c:\users\matuszczyk.matuszczyk-pc\documents\unreal projects\3d_navmesh\source\donnavigationsamples\Actor_Class.h(9): error C2059: syntax error: 'public'
2>c:\users\matuszczyk.matuszczyk-pc\documents\unreal projects\3d_navmesh\source\donnavigationsamples\Actor_Class.h(10): error C2143: syntax error: missing ';' before '{'
2>c:\users\matuszczyk.matuszczyk-pc\documents\unreal projects\3d_navmesh\source\donnavigationsamples\Actor_Class.h(10): error C2447: '{': missing function header (old-style formal list?)
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(8): error C2653: 'AActor_Class': is not a class or namespace name
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(11): error C2065: 'PrimaryActorTick': undeclared identifier
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(11): error C2228: left of '.bCanEverTick' must have class/struct/union
2>  C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(11): note: type is 'unknown-type'
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(13): error C4508: 'AActor_Class': function should return a value; 'void' return type assumed
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(16): error C2653: 'AActor_Class': is not a class or namespace name
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(18): error C2653: 'Super': is not a class or namespace name
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(23): error C2653: 'AActor_Class': is not a class or namespace name
2>C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Source\DonNavigationSamples\Actor_Class.cpp(25): error C2653: 'Super': is not a class or namespace name
2>ERROR : UBT error : Failed to produce item: C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\Plugins\DonAINavigation\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-DonAINavigation.exp
2>  Total build time: 3,89 seconds
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(37,5): error MSB3073: The command ""C:\Program Files\Epic Games\4.10\Engine\Build\BatchFiles\Build.bat" DonNavigationSamplesEditor Win64 Development "C:\Users\Matuszczyk.Matuszczyk-PC\Documents\Unreal Projects\3D_navmesh\DonNavigationSamples.uproject" -rocket -waitmutex -2015" exited with code -1.
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========