Pathfinding in Unity DOTS! (Insane Speed!!!)

preview_player
Показать описание
Let's implement Pathfinding in Unity DOTS, we're going to write everything in a Data Oriented way (Structs) in order to benefit from massive performance!

Here's the follow up video covering Pathfinding in Unity ECS

A* Pathfinding in Unity

What are Value Types and Reference Types in C#?

If you have any questions post them in the comments and I'll do my best to answer them.

See you next time!

#unitytutorial #unity3d #unity2d

--------------------------------------------------------------------

Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.

I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.

--------------------------------------------------------------------

Рекомендации по теме
Комментарии
Автор

Check out that insane speed! How many Units do you think this can support? What kind of stress test would you like to see?

🎮 Play 7 Awesome Games (Action, Strategy, Management) and Help Support the Channel!

CodeMonkeyUnity
Автор

I never thought I would see a return to the old coding patterns that I learned when I started mainframe coding in the early 90's. Before OOP became a thing, everything was data oriented and parallel processing was an option for increased throughput. What goes around comes around.

ronsargeant
Автор

I thought I was a good programmer but watching you code made me believe that I still have a lot to learn.

SkaiCloud
Автор

Awesome as always ! Your knowledge on Unity, C# & Dots far surpasses most of the YouTubers in the field of game development.

rahulkumarjha
Автор

I’ve read that it’s best to use Manhattan Distance (ie no diagonals) for your H. This allows you some leeway for walls etc and doesn’t give you an h that’s consistently too low.

Also I recommend setting the square root of 2 as a constant and using that instead of the approximated 1.4

Also, you can run the code switching the destination and the source and then you don’t have a reverse array at the end.

justinwhite
Автор

Amazing job! Keep continuing with the ECS series because you are the only one who does them right! One question: could you cover animation and sounds(and possibly networking if that exists) in ECS? THANK YOU A LOT FOR YOUR CONTENT

andreicirstea
Автор

It's awesome you're doing something with Unity DOTS! I would like to see more!

KiwiGalaxyDev
Автор

I appreciate all the different versions you tested here for performance, especially how you showed jobs/burst without ECS. Performance increases from switching to burst jobs can be very, very good. And while ECS is a little crazy, and still seems to be subject to development changes, jobs seems very ready.

varnonzero
Автор

Everytime I see a video on Dots speed increase my jaw still drops to the floor :')

lemurza
Автор

Thanks for the video! Another optimization for large maps: use a NativeList<PathNode> instead of a NativeArray<PathNode> which currently makes the whole algorithm quadratic due to its initialization. Using the NativeList, you can create the PathNodes only when necessary, and use a NativeHashMap<int2 position, int index> for keeping track of the indexes in the NativeList (I'm simply incrementing the indexes). From my testing this helps for maps around 500 by 500 and larger. With a map of 1000 by 1000, pathing from (0, 0) to (999, 999) with 50 instances, it takes around 730ms with the new method, and 1080ms with the current NativeArray implementation. The most serious optimization would be to implement a NativePriorityQueue to use as the openList to bring down the linear min FCost search to logarithmic.

supertrooperdk
Автор

Here's the follow up video covering Pathfinding in Unity ECS

CodeMonkeyUnity
Автор

I need to learn to implement my code this well, the burst compiled version of the A* pathfinding you made is >10, 000 times faster than the origional one you made!

Edit: Thank you Code Monkey for reading this, even after 3 years <3. Your videos have truly helped me learn Unity more than any other channel, thank you for all your hard work ;)

rancorjoy
Автор

Wonderful! I just started exploring cache friendly layout, DOD, and Unity's ECS and this is one great example of its applications..

Question though, one of the blogs I read mentioned that grid-based data is not recommended for ECS due to the neighboring cells/node that causes jumps in the data that I assume might cause cache misses (most likely because of the vertical and diagonal checks). Question is, how come the neighbor checking doesn't seem to have caused that problem? Thank you in advance :D

chilldude
Автор

Great work cant wait to see how much quicker it is on complex terrain following a moving target

tomnorc
Автор

Great video. Just one note; At 16:42 you never added any code to the positive case. In general, the condition here is unnecessary since you check the condition inside the CalculatePath function.

crion
Автор

At 9:40 if like me you can't access to NativeList : Project Settings --> Package Manager --> Enable Preview Packages
Go to Package Manager --> Packages: In Project --> (+) --> Add package from git url --> com.unity.entities --> add

Floyna
Автор

Thanks for the tutorial, after I done it myself, I found it's really a good way to work in small size pathfinding which under 300*300 grids, when I try 1000*1000 even 500*500, it spend a really unimaginable long time, I have no idea about how to optimize it and my game really need that size.Btw, sorry for my English lol.

zetanhwang
Автор

For those who are having the issue with the 'NativeList' not being available, Make sure you have the unity Entities package installed onto your project.

NoirPhoenix
Автор

using the index is a nice way around the restriction on recursive structs.

th_CAV_Trooper
Автор

I dont understand. In this video your code does not use DOTS at 20:00 moment. Seems like you just wrote unoptimized code in previous lesson. I write A* myself with classes only and it works ~3 slower in my machine than your written by sctructures.

penguin_of_linux