Here's some Pathfinding with Unity ECS that can go up to 50,000 units! These complex DOTS videos take a long time to make so if you find them helpful consider supporting on Patreon or picking up the Game Bundle 📍 www.patreon.com/unitycodemonkey 📦 unitycodemonkey.com/gamebundle.php
@danmac645 жыл бұрын
Love these, keep it up!
@davtam5 жыл бұрын
Bought the bundle and look forward to keep on supporting you in the near future, you are really good at articulating DOTS.
@CodeMonkeyUnity5 жыл бұрын
@@davtam Awesome! Thanks!
@pureay27004 жыл бұрын
@@CodeMonkeyUnity is it possible to make a grid using ecs or to make a 3d dynamic buffer or ecs compatible array. I'm converting my voxel system to ecs and i just can't figure out a ecs equivalent to [, ,] array.
@joris94675 жыл бұрын
Please do the simple RTS, would really like to see some of these things in a complex environment. Always nice to watch!
@saehoon2002 Жыл бұрын
It would be super cool and useful for this tutorial to be updated with new ecs version 1.0.11
@mattshroom335 жыл бұрын
ECS ! Thank you!
@serious075 жыл бұрын
It would be cool to see this system with an agent radius added to it, so that the units do not overlap and go around each other.
@CodeMonkeyUnity5 жыл бұрын
Yeah I've thought about making a Unit Avoidance System using the Quadrant System I made previously as a base kzbin.info/www/bejne/noGXh6hsf8etidE Should be pretty fast
@SkeletonBill2 жыл бұрын
This seems to be outdated as of Entities 0.51, the syntax doesn't work, and rolling back to an old version caused a bunch of other problems. Any chance of an updated video for 2022?
@CodeMonkeyUnity2 жыл бұрын
Yeah I haven't touched DOTS in some years, no idea how different the code is nowadays. I'm only planning on getting back to it after 1.0 release sometime next year.
@c03354 жыл бұрын
12:55 I had to define PathFollow as a struct, otherwise it confused the compiler when running the Entities.ForEach in the PathFollowSystem.
@briangelhorn4074 жыл бұрын
that's true
@briangelhorn4074 жыл бұрын
probably due to updates to the entity system because a couple of months have passed since this video and for example now you do not need to do the temporary ijob, you just have to place the same as the componentsystem to the dynamic buffer and it works
@JRX4 жыл бұрын
When there are changes in the scenario while the unit is still in movement, it simply passes through the new obstacle. By changing the unit's behavior to redo the pathfinding when there is a change in the scenario, that was solved, but then a problem became obvious: When the unit tries to find a path and is not in the center of a node, the unit goes back to its center, and that could allow exploitation from the player. A simple fix for it was to remove the initial node from the path in the calculatePath method, and that made pathfinding retries seamless. I plan to make a free path tower defense game, and this is going to be very useful. Thank you very much.
@CodeMonkeyUnity4 жыл бұрын
Yup normally that's what I do, calculate the path again if something changes or just over time and always ignore the first path position.
@tfmate-ij5em2 жыл бұрын
any way to avoid graph recreation for each unit?
@dreirxge2 жыл бұрын
This could definitely be used for management type games.
@dsfmdiya75005 жыл бұрын
Me: I wanna sleep because it’a 12 o’clock where I live Code Monkey: Drops this video Me: SLEEP IS FOR THE WEAK
@adamodimattia5 жыл бұрын
Fantastic material as always. I have a small problem though, after converting to entity my unit becomes invisible, it still is in the debugger, but apparently is not visible. And yes, an RTS game in DOTS would be amazing! Please do.
@CodeMonkeyUnity5 жыл бұрын
Do you have the Hybrid Renderer package installed?
@adamodimattia5 жыл бұрын
@@CodeMonkeyUnity No, I completely forgot about it! It is that for sure. Thanks
@antonlovchikov6303 жыл бұрын
Hi! Thank you for the project for downloading! Trying to get it running but get an error Assets/DOTS_Pathfinding/Scripts/PathFollowSystem.cs(65,123): error CS1061: 'EntityCommandBuffer' does not contain a definition for 'ToConcurrent' and no accessible extension method 'ToConcurrent' accepting a first argument of type 'EntityCommandBuffer' could be found (are you missing a using directive or an assembly reference?) Did they changed the API? Do you know how to fix this part?
@gladiumcaeli5 жыл бұрын
Really curious now to see how many units it can handle with both system being used
@TylerButh4 жыл бұрын
Just an FYI, I am literally following along with some of this code and a few times you've done massive deletes and reformatting and you sped up the code so that it was really really hard to see what you actually did. I can figure it out looking at before and after but it makes it pretty confusing. An example is around 11:30. You added pathPositionBuffer then you perhaps make a delete and comment out some code but it goes very fast so it's hard to tell.
@l.driver-williams54824 жыл бұрын
Nice tutorial, very informative. Just one question though. Is there a specific reason you used your own implementation of grid rather than the one packaged with unity?
@rafalwilczek23013 жыл бұрын
Thinking, how to set Grid is already Occupied when unit stay now here, every step checking if path is still valid & next grid is not occupied by somebody. Thinking how to implement, "Collisions Like", 2 units can't stay/walk on same grid in same time :) somebody must be first
@yancur2 жыл бұрын
Unfortunately this no longer works with newer version of DOTS :( It even crashes the compiler.
@CodeMonkeyUnity2 жыл бұрын
The syntax is going to be very different nowadays but the core data oriented logic is still applicable
@yancur2 жыл бұрын
@@CodeMonkeyUnity Yeah, I tried to change the code according to the new syntax, but when the compiler itself has thrown an exception and prompted me to send BUG report, I have given up. That's way over my current skill to delve deeper. But yes, definitely the logic of the video still applies. Thank you!
@Kryonnnn4 жыл бұрын
"at 26:15" if you update unity now [NativeDisableContainerSafetyRestriction] work on the DynamicBuffer and everything goes pretty smothly
@Kryonnnn4 жыл бұрын
@@LaCreArthur i had a similar issue, but it occur only cus I had a 200x200grid
@scriptsengineer4 жыл бұрын
Note: ComponentSystem is deprecated after 0.11, use SystemBase instead.
@ChadAKA4 жыл бұрын
Have you gotten it to work with SystemBase? I'm having a hard figuring this out.
@scriptsengineer4 жыл бұрын
@@ChadAKA Yes, but no perfect code: this update code protected override void OnUpdate() { int2 gridSize = buildCellSystem.dimensions; List findPathJobs = new List(); NativeList jobHandles = new NativeList(Allocator.Temp); NativeArray pathNodeArray = PathUtils.GetPathNodeArray(buildCellSystem.cells, buildCellSystem.dimensions); var ecb = commandBufferSystem.CreateCommandBuffer(); Entities.ForEach((Entity entity,ref PathfindingParams pathfindingParams)=> { NativeArray tmpPathNodeArray = new NativeArray(pathNodeArray,Allocator.TempJob); FindPathJob findPathJob = new FindPathJob { gridSize = gridSize, pathNodeArray = tmpPathNodeArray, startPosition = pathfindingParams.startPosition, endPosition = pathfindingParams.endPosition, entity = entity, offsetDistance = pathfindingParams.buildSize }; findPathJobs.Add(findPathJob); jobHandles.Add(findPathJob.Schedule()); ecb.RemoveComponent(entity); }).WithoutBurst().Run(); JobHandle.CompleteAll(jobHandles); foreach(FindPathJob findPathJob in findPathJobs) { new SetBufferPathJob { entity = findPathJob.entity, gridSize = findPathJob.gridSize, pathNodeArray = findPathJob.pathNodeArray, pathfindingParamsComponentDataFromEntity = GetComponentDataFromEntity(), pathFollowComponentDataFromEntity = GetComponentDataFromEntity(), pathPositionBufferFromEntity = GetBufferFromEntity() }.Run(); } pathNodeArray.Dispose(); }
@scriptsengineer4 жыл бұрын
@@ChadAKA Note: gridSize is my class of code cell grids
@ChadAKA4 жыл бұрын
@@scriptsengineer Thank you so much! This worked great.
@people_fly135 жыл бұрын
there is no JPS (not JPS+) tutorials or unity implementation available in web at all, it would be great if you make such video, cause i do not see reason to still use simple A* when it is so bad at performance compared to JPS
@CodeMonkeyUnity5 жыл бұрын
That's definitely something I want to look into but basic unoptimized DOTS Pathfinding is already insanely fast so not sure if the added complexity is worth it.
@zerovega96043 жыл бұрын
Does this still work? Can't even get the sample scene working, the sprite doesn't show up on the grid. All i did was add the Project Files and Utilities and installed Entities. Only had one deprecation that seems to have been fixed with .ParallelWriter
@RTWrename3 жыл бұрын
I am assuming that I can use this with a tileset? if so what should I look for to implement it on the tileset?
@LaCreArthur4 жыл бұрын
Hello, I'm using this code for some agents of my game and I have a performance issue, if my game runs for a while I have some frames that freezes, using the profiler I have a big spike with 98% of it being the "Pathfinding:FindPathJob (Burst)" Nothing special happened in the gameplay, just random frame freezes after 3-5 minutes... Anyone have any idea what it can be ? Note that I have updated the packages for [NativeDisableContainerSafetyRestriction] to work on the DynamicBuffer
@rafalwilczek23013 жыл бұрын
If i understand good, the jobs are made in order? Meaning in multiplayer server, when i handle server to do jobs, it gonna make one by one with so efficiency? Won't making some parrarel example add > occupied position to list in same time when somebody adding it & than 2 player gonna move on same tile ;p Bcs if its so efficient, its amazing. To Handle Many Player computations + many monsters computations as well!
@nikowill69794 жыл бұрын
Great tutorial. Is there any way to let the entity to chase the player...set endPos as player position seems not enough.
@KyubIchigo23 жыл бұрын
Is it necessary to have so many separate files or is this something you're doing for clarity sake? I could see this being a problem when making a game with so many systems and components.
@TwoVera4 жыл бұрын
Please show us how you did the animation with seperate meshes for your characters
@CodeMonkeyUnity4 жыл бұрын
I cover how my animation system works here kzbin.info/www/bejne/Z2LGaqWNh9SngJo
@tomnorc32495 жыл бұрын
great video i'm a little confused on how you get the data from the game object grid though, still awesome stuff!
@CodeMonkeyUnity5 жыл бұрын
The Grid class is fully created in this video kzbin.info/www/bejne/rZKopHqrYpJshpo kzbin.info/www/bejne/bpvVcoqqfp2Fjsk So here all I'm doing is cycling through the grid and testing if the isWalkable boolean is true or false
@tomnorc32495 жыл бұрын
@@CodeMonkeyUnity thank you! i managed to hook my own grid up that automatically checks my terrain for unwalkable parts thanks to this, excellent ecs work, just finished watching the rest of the videos, thanks again
@provunity35824 жыл бұрын
Why is not possible to add a 300x300 cell grid? Seems like it hasn't enough time to get updated. Does anybody know any quick fix for that?
@leonidus1012 жыл бұрын
Does the new update in Unity 03.2021 LTS make this code obsolete?
@CodeMonkeyUnity2 жыл бұрын
The Unity version shouldn't matter much but what does matter is the Entities version which just received a massive update. I haven't looked into it yet but I would assume there's quite a lot of syntax changes however the data-oriented logic for handling pathfinding is still valid.
@treymtz Жыл бұрын
IMPORTANT FOR NEW ECS 1.0.1: The workflow has changed. There is no component called convert to entity, because you instead create a new sub scene and place the gameobject in there to bake it into an Entity.
@mana204 жыл бұрын
Any idea if it scales well for larger maps? I guess you could use the hierarchical nodes to reduce some of the blunt force path finding.
@CodeMonkeyUnity4 жыл бұрын
Sure it scales very well and continues to be very fast in a large map. But regardless of how fast it is at some point you need to use multiple maps, can't have the entirety of Skyrim in a single Pathfinding map.
@돼지비빔밥4 жыл бұрын
진심으로 감사합니다.
@omarkhalaf87355 жыл бұрын
Hello Sir, Code Monkey I'm new to the channel but i find this really useful and helpful and i enjoy your content, also i plan on watching some if not all of your series regarding game dev, so after all of this my question is : could you give an advice from which source should i learn beginner and advanced either game dev or C# in general ? i know some of the sources myself but i'd love to know your recommendations. Thanks, sorry for the long comment.
@CodeMonkeyUnity5 жыл бұрын
If you're a complete beginner in Unity watch these videos to get acquainted with the engine kzbin.info/aero/PLzDRvYVwl53vxdAPq8OznBAdjf0eeiipT After that try making a complete game like this kzbin.info/www/bejne/mGa6oaGfbrCDn80
@omarkhalaf87355 жыл бұрын
@@CodeMonkeyUnity Thank you sir for your guidance, i will make sure to follow your instructions.
@MNenad4 жыл бұрын
Awesome video as always! But even with your files I could't reproduce the project in a version that is lying flat on the ground (y swapped with z-axis). Somehow the grid that is used for pathfinding doesn't match the grid from the Grid class (visible in scene)... I cannot get the grid position recalculated into world position properly. Did someone experience similar problems? Thx in advance
@andrewshandle5 жыл бұрын
I need to rewatch the part on the race condition after the Super Bowl is over. I'm a little confused why the system is convinced that accessing a Component from a specific entity would be unsafe, or is it specifically because it's a Buffer? Let's say you had a job to handle projectiles, at any given time you might have hundreds of bullets/arrows/rockets/frying pans flying around the screen, so would those need to be unsafe to be able to use multiple threads?
@CodeMonkeyUnity5 жыл бұрын
The issue is potentially having 2 separate jobs accessing the array with the same entity index and writing to it. You have 2 jobs trying to write to the same memory which would cause a crash, the compiler tries to protect you from that by disallowing that by default. This system uses the NativeArray for the Pathfinding which is why I cannot use a IJobForEach or IJobParallelFor, when you use those interfaces it automatically accesses only a single index so it works fine concurrently without disabling safety.
@andrewshandle5 жыл бұрын
@@CodeMonkeyUnity Ah, okay, that makes complete sense. I'm cooking a bunch of food for a Super Bowl party, so I didn't have a chance to go back and watch that part again. ;) Your videos on DOTS have been great, so keep up the great work!
@simeonvasilev40744 жыл бұрын
Hello, first thank you for the tutorials that you are making, they are really useful. I just have one question - I am not able to find MeshUtils in Utils package that you provided, are you able to share it or just to mention, what is the purpose of GetQuaternionEuler method, it should return float based on input float(I am a little bit confused here). Thanks in advance!
@stien3874 жыл бұрын
Very nice video! I tried to apply this in my own project, but I have a really hard time providing the paths back to my "normal" object based scripts and mono behaviours. Do you have any suggestions on how I can provide a list of vectors / grid positions back to a mono behaviour after the job is complete. Thanks!
@CodeMonkeyUnity4 жыл бұрын
I covered using this mixed with Game Objects here kzbin.info/www/bejne/jqDQnYd-ntl0q8k
@SuperKemito5 жыл бұрын
I would like to see your approach to using more physics in ECS. It failed hard to do so in GGJ2020. ECS also limits using skin mesh renderer, animations?
@BeerfootBandit4 жыл бұрын
this is some pretty amazing stuff! Can entities be enabled/disabled for pools? I was thinking about making a small simple DOTS rts based on your tutorials
@blakeguyan26624 жыл бұрын
Hey, When i convert over the script for my pathfinding i get a whole raft of errors stating i need an object reference to a non static field. I realise that its because you converted the function calculatePath to a static, i just dont understand why i am getting it and you didnt?
@blakeguyan26624 жыл бұрын
OK Mystery solved.. i had a rogue closing bracket after the Dispose commands that locked off the functions being called from the main function which was the root of the error! also, anyone coming from the last tutorial might run into a weird pathfinding error caused by the grid size being too small! you need to always make sure your grid size is LARGER than the coordinates you are trying to pathfind to, if you find you are getting some odd results, thats why!
@nandorbacso46255 жыл бұрын
What's the difference between this and the DOTS video?
@CodeMonkeyUnity5 жыл бұрын
This one applies that Pathfinding code to the Entity Component System so you can add components to request a path and calculate it
@stien3874 жыл бұрын
Hi Code Money, great content! It is very informative and help me out a lot! I have one question, in my own project I try to overlay a pathfinding grid over an existing tile-based Gameworld and do a an physics overlap collider check for every cell in the grid. I was wondering if there is a better solution to this. Thank you! Keep up the great work!
@CodeMonkeyUnity4 жыл бұрын
If you do it very rarely then yes that is a very nice and easy approach. It only becomes an issue if you constantly update your Pathfinding map, if so then it would be best to keep a separate grid just holding a boolean and you update that manually when you modify the map.
@somacruz105 жыл бұрын
oh is this can be helpful for 3d rts?
@CodeMonkeyUnity5 жыл бұрын
Its especially useful for RTS where you have tons of units and complex maps
@kira76835 жыл бұрын
This is some wizardry
@paulrobinson54905 жыл бұрын
Hi CM. I'm in the process of putting a game onto the play store, have you any idea what I name the pricing template, is it the game name or something else. There is nothing to suggest what it should be and don't want to screw up :(. Nice vid by the way, as usual :)
@mark-johnhenry2465 Жыл бұрын
what version of unity is this using and ecs?
@CodeMonkeyUnity Жыл бұрын
This video is pretty old by now so chances are the syntax has changed a lot. Although the high level core concepts are still applicable.
@mark-johnhenry2465 Жыл бұрын
@@CodeMonkeyUnity thanks for the response. I have successfully converted to v1 I believe. however there's a few more steps I need to complete. one of them is attaching am missing mono behaviour on prefabentitycomponent which is in the scene. could you tell me what script this. mono behaviour also missing on the unit game object.. it would be a great help
@mark-johnhenry2465 Жыл бұрын
never mind I have the project working in the latest ecs.
@hbirtt4 жыл бұрын
I feel like this is one of those things that is simple once it clicks, but it's still pretty abstract to me after watching this. All of the references to other code and concepts made it hard to follow for me. I have learned a lot from your videos, so I hope you see this for constructive criticism because that's what I'm going for. I'm sure this stands as a great "tie things together" video for people who fully understand all of these concepts. I'm going to put together which order to watch all of the related videos in and I'm sure I will get it all then. Maybe you could create a playlist with these in the order to follow, assuming you haven't done that?
@CodeMonkeyUnity4 жыл бұрын
Are you familiar with the core A* Pathfinding algorithm? If not I covered how it works here kzbin.info/www/bejne/l524YWeeq99pgpY This ECS version is a more complex version of that same algorithm.
@hbirtt4 жыл бұрын
@@CodeMonkeyUnity The A* algorithm is actually pretty simple, so that wasn't bad. It was dots and some of the other stuff that I didn't keep up with. I'm pretty sure you have covered all of this individually. Just need to figure out which order to watch in. Again, great stuff, and I appreciate it. Just pointing out what my experience was finding this video first.
@CodeMonkeyUnity4 жыл бұрын
@@hbirtt Yeah I understand, on KZbin each video has to be relatively small and I cant control which one people see first, I put all my DOTS videos in this Playlist kzbin.info/aero/PLzDRvYVwl53s40yP5RQXitbT--IRcHqba
@hbirtt4 жыл бұрын
@@CodeMonkeyUnity That's great. I didn't realize how much content you had around the subject. You bring a lot of good stuff to the table man. Thanks. I've migrated my latest project to Godot just to see how I like doing the same project in each, but I'm sure I'll be using Unity again and this will be helpful stuff.
@Taobyby2 жыл бұрын
I bought all your games. Do I owe you now? Just kidding, thx for your videos. 🙂 Friendly criticism: Sometimes you skip important parts in your videos, or change some parts between videos, which forces me to download the project files from your site. While this is no big problem, to me it feels kinda like (self)cheating and sometimes it takes a lot of time to find the little difference you included between 2 videos. :-)
@CodeMonkeyUnity2 жыл бұрын
I hope you like the games! Thanks! That's the issue with KZbin videos, if I make them super long then no one watches, so I have to be very careful to only show the interesting parts, no one will watch a video of me refactoring some code to prepare for the "next" tutorial. To solve that is why I have my courses, in there I can spend as much time as needed going step by step without worrying about the algorithm punishing me.
@OIL9385 жыл бұрын
Is ECS ready to use?
@457Deniz4575 жыл бұрын
Seems so ! :D
@dr_UiD5 жыл бұрын
Yes, if you willing to write almost every system yourself. Animation, pathfinding, rendering, input, ui, physics interpolations😊
@WhoOne5 жыл бұрын
Still in preview, but quite useful right now for some parts of the game.
@INeatFreak5 жыл бұрын
if you're not gonna make just some prototype/experiment stuff i would suggest you to wait for a while till unity devs make ecs as flexible as the current one.
@dr_UiD5 жыл бұрын
@@INeatFreak yeah, for 2-3+ years 🤣
@haithammahmoud68255 жыл бұрын
can u please make tutorial how to make 3D dynamic roads (path) or floors like tycoon games thanks
@mrcyberpunk5 жыл бұрын
Interesting but I'd like to see how it performs with actor to actor collisions. I think the number would be half that. Still impressive though.
@CodeMonkeyUnity5 жыл бұрын
Yup I'm planning on combining this Pathfinding with DOTS Physics by having units calculate a path through a small tunnel and push each other around to see how performant that is.
@juliusborn59533 жыл бұрын
@@CodeMonkeyUnity Is there some video about that?
@humanDNA5 жыл бұрын
Comment for YT algorithm
@INeatFreak5 жыл бұрын
is this a reupload?
@falsecalamity5 жыл бұрын
No I believe this is the follow up to the Pathfinding in unity with DOTS video
@CodeMonkeyUnity5 жыл бұрын
Like Daniel said, this is a continuation of the previous video. In that video I covered making Pathfinding with the Job System and the Burst Compiler and with this one I apply it to the Entity Component System.
@naeemali29425 жыл бұрын
game graphics quality is low when i play it on an android device for testing Plz help plz help
@roudikk4 жыл бұрын
For future vidz.. please.. dark editor.. my eyes
@roudikk4 жыл бұрын
oh and great vid
@CodeMonkeyUnity4 жыл бұрын
Sorry, my eyes can't handle the dark theme
@roudikk4 жыл бұрын
@@CodeMonkeyUnity all good this video helped me a lot, it's so weird that after 11 months from this video still no out of the box mav mesh navigation properly im dots, or i cant find it 🤷♂️
@arsenbabaev10224 жыл бұрын
SO SIMPLE YEAH
@tiagosousa52784 жыл бұрын
the amount of ads.
@CodeMonkeyUnity4 жыл бұрын
Feel free to support on Patreon and enable AdBlock
@gamedev85674 жыл бұрын
To be fair, it's a bit hard to follow the tutorial with all of the speeded-up time when you code. It makes it hard to write the code along with the video, especially when you scroll up and down changing little things. It's all speeded-up, which requires me to stop the video multiple times in order to write the code and try to make sure I'm writing it correctly. Now, I know there is a package for every video available free to download, but it's just not the same, you know? You are less likely to learn when copy-pasting code. And I know, the video might get over 2 hours long if you don't speed-up the coding, but for a complicated topic, such as ECS, it would make a lot of sense. I believe that only dedicated people would watch it and actually try to understand how it works, while complete beginners wouldn't be able to understand it either way. Unless they study the basics of c# and unity first, of course. So I just wanted to ask you, what do you think? I really like your videos, and I'll respect any choice you make and will try to follow along, even if it's sometimes hard.
@fnaf00615 жыл бұрын
Hi
@dsfmdiya75005 жыл бұрын
FNAF 00 Hi
@fnaf00615 жыл бұрын
Hi
@fnaf00615 жыл бұрын
subscribe like
@MuftahDev5 жыл бұрын
JUST TELL ME HOW TO INSTALL THE FRICKING UTILIS FROM YOOOOU! :(
@CodeMonkeyUnity5 жыл бұрын
Just open the Unitypackage and it will all be added into your scene