UNITY DOTS (ECS) - Beginners Guide

  Рет қаралды 19,710

Freedom Coding

Freedom Coding

Күн бұрын

Пікірлер: 140
@ashishitD
@ashishitD 2 ай бұрын
If anyone is unable to spawn objects in the systems section: 9:55 add '!' to the return condition to invert the condition
@deusxunveiled
@deusxunveiled 10 ай бұрын
I've been looking at DOTS tutorials for a while and this video has the clearest explanation for me who wants to switch from OOP to DOTS. Thank you!
@freedomcoding
@freedomcoding 10 ай бұрын
I am glad you enjoyed it!
@MrRedpearl
@MrRedpearl 11 ай бұрын
Awesome! I like how you don't explain while typing, you type and explain separately. This was exactly what I needed. I'll test this out ASAP. Thanks!
@freedomcoding
@freedomcoding 11 ай бұрын
Thanks! I am glad you like my approach.
@MrRedpearl
@MrRedpearl 11 ай бұрын
@@freedomcoding Keep up the good production! Subscribed
@mclee5081
@mclee5081 10 ай бұрын
You made the Best unity DOTS tutorial video I've watched.
@freedomcoding
@freedomcoding 10 ай бұрын
I love to hear that!
@magickomchanell4556
@magickomchanell4556 4 ай бұрын
best English tutorial I've ever seen, thanks for the video!
@freedomcoding
@freedomcoding 4 ай бұрын
I love to hear that. More are coming!
@Chubbs70000000
@Chubbs70000000 Жыл бұрын
Awesome video! Thanks! Looking forward to more ECS tips and guides
@freedomcoding
@freedomcoding Жыл бұрын
Thanks a lot! If you have any suggestions, let me know!
@idekman
@idekman 2 ай бұрын
you filmed this on my birthday thats craaaaay
@freedomcoding
@freedomcoding 2 ай бұрын
I see I recorded it almost a year ago, so I wish you happy birthday upfront!
@adeelthedeveloper
@adeelthedeveloper 11 ай бұрын
I really enjoyed the video and I am looking forward to seeing more in the future.
@freedomcoding
@freedomcoding 11 ай бұрын
Thanks a lot!
@hacbit
@hacbit Жыл бұрын
Love this tutorial. But there are still some small flaws, such as should mean , and the if judgment condition in CubeSpawnerSystem should be inverted. Although these can be speculated, it will inevitably make me confused, so I hope you can carefully proofread the script in the subsequent tutorials.
@freedomcoding
@freedomcoding Жыл бұрын
Thanks for pointing out the flaws. I will do better!
@zalam627
@zalam627 5 ай бұрын
Thank you :)
@vardanbetikyan4117
@vardanbetikyan4117 4 ай бұрын
Spent a good while looking for this, thanks!
@xuanquy1200
@xuanquy1200 Жыл бұрын
Can you make a video tutorial on collision handling and raycasting in Unity DOTS?
@freedomcoding
@freedomcoding Жыл бұрын
That is a good idea.
@BigDaddyGameDev
@BigDaddyGameDev 11 ай бұрын
Fantastic tutorial! Thank you.
@aleqkzander
@aleqkzander 10 ай бұрын
You explained that mess very good - thanks for that!
@freedomcoding
@freedomcoding 10 ай бұрын
Thanks!
@시마문
@시마문 7 ай бұрын
Your videos are very helpful and explain in detail from a beginner's perspective. I am especially impressed by the part where you always teach with a bright expression and voice. I also watched videos with the opposite feeling from other KZbinrs, and I felt like I was becoming negative as well. If I knew how to speak English well, I would have learned it from you. I look forward to your good videos in the future. 👍👍
@freedomcoding
@freedomcoding 7 ай бұрын
Thank you! I really appreciate that and will keep making better videos.
@igeprogrammer
@igeprogrammer 4 ай бұрын
Can you make a video about DOTS and NavMesh combination?
@freedomcoding
@freedomcoding 4 ай бұрын
Hi, I already made one about NavMeshQuery. That is even more optimized! kzbin.info/www/bejne/mKC3ZWWwqrydrcU
@TREXYT
@TREXYT Жыл бұрын
I would love to see a video on unity ecs/dots where a player shoot on an object with bullets, simple project
@freedomcoding
@freedomcoding Жыл бұрын
Good idea! I still have many tutorials about DOTS to make, so I will get to that some time.
@TREXYT
@TREXYT Жыл бұрын
@@freedomcoding alright, i've seen your project in 2d i think i can do similar based thing in 3d based on your videos 😁
@freedomcoding
@freedomcoding Жыл бұрын
You definitely can! DOTS works better with 3D, it doesnt really support 2D.
@HuKuTa944
@HuKuTa944 Жыл бұрын
Hi! Thanks for tutorial. I followed your video and I got some issue. I run the game and see haw "next spawn time" is changed but nothing is spawned. No cubes in scene hierarchy. Entity package version: 1.0.16
@hacbit
@hacbit Жыл бұрын
Try changing it to "if (!SystemAPI.TryGetSingletonEntity(out Entity SpawnEntity)) { return; } ...", because nextSpawnTime must be obtained after the cubeSpawner Entity is created.
@freedomcoding
@freedomcoding 11 ай бұрын
That could be it. I am sorry for leaving the error in the tutorial.
@HuKuTa944
@HuKuTa944 11 ай бұрын
@@freedomcoding My project uses built-in render pipeline. I started a new URP project and now I can see the cubes and spawner also works. But I dont see created entities in editor hierarchy. I tried to up package version but I got other error with dependencies)
@freedomcoding
@freedomcoding 11 ай бұрын
@@HuKuTa944 Are you looking in the entities hierarchy? It is in window and entities I believe.
@HuKuTa944
@HuKuTa944 11 ай бұрын
​@@freedomcoding Oh, my bad. I looked at the old scene hierarchy. Now I opened entities heirarchy window and can see entities in runtime) Solution: Windows -> Entities -> Hierarchy
@LanciaSiluri
@LanciaSiluri Ай бұрын
So an "entity" script can just be thrown on a empty game object in the scene, considering it will just execute code that controls other objects
@freedomcoding
@freedomcoding Ай бұрын
What do you mean by entity script? A component or system? Only components can be placed on entities. The components only hold some data. The system can just stay in the project and that is what controls the other objects.
@mannguyenduy3688
@mannguyenduy3688 10 ай бұрын
hello, is there a playlist of unity dots tutorial on your channel? i find it pretty hard to follow the right path
@freedomcoding
@freedomcoding 10 ай бұрын
Hi, I have just created it. I am always lazy to do so even though it takes no time :D
@mannguyenduy3688
@mannguyenduy3688 10 ай бұрын
@@freedomcoding thanks bro
@mihakramberger9733
@mihakramberger9733 Жыл бұрын
Perhaps a question, on what kind of hardware CPU/GPU you achieved 700 FPS ? I'm getting 250 with ECS at most with Ryzen 5 series and GF 3070 ?
@freedomcoding
@freedomcoding Жыл бұрын
Hi, I have I5-10400F and GTX 1660 super, so nothing fancy. There is a big performance difference in the build and in the editor. Also it may not be optimized the best, but if you build it, you should be getting a lot more FPS.
@stormer268
@stormer268 9 ай бұрын
Mine is Intel i7 12700K, 32G ram, 3060. When spawn rate is 0.1 got 112FPS.
@xrystal
@xrystal 11 ай бұрын
I was enjoying the tutorial, however, when I tried this on version 2023.2.3f1 version of the editor. The cube does not spawn when I compared the results at 12:00 point. I can't see anything different with my screen and yours code wise, but, my cube prefab ( created 3d cube in scene and dragged to project and then deleted from scene ) looks very different from yours at the 7:47 mark. Was your cube created similarly, or via something like Blender and imported ? I also had a memory allocation error appear inside the entity hierarchies window, so maybe there is something else that needs to be done in 2023 version for this to work.
@xrystal
@xrystal 11 ай бұрын
I will try 2023.2.5f1 to see if they fixed the problems that might be at their end and also the LTS versions for 2022 I still have installed. I'll update the results.
@freedomcoding
@freedomcoding 11 ай бұрын
I havent used DOTS with 2023 yet... The cube is just a default one from Unity. The entity is not spawning at all or you just dont see it? (take a look to Window-Entities-Hierarchy)
@xrystal
@xrystal 11 ай бұрын
It's not in the entity hierarchy at all and the spawn timer isn't updating. The latest 2023 had the same memory leak issue so probably is failing due to that error. Tried rolling back to 2022.3.17f1 but that had conversion issues as did 2022.3.7f1. But these were conversions of the project rather than new creations. So will try with the 2022.3 versions from the start and see what happens. Thanks for the response.
@xrystal
@xrystal 11 ай бұрын
Well, I manually created the project in all versions of the editor I have again, and can confirm that the cube visual in the project was like due to me foolishly loading up the 2D URP instead of 3D URP. All new projects correctly showed 3D cubes and not 2D squares rofl. But, in all instances there is a memory allocation error in the entity hierarchy. I thought maybe it was the entities version, but nope, same version of the package. I am going to install one more version ( the precise version you have 2022.3.13f1 ) and see if it works then. If not, I can only put it down to user error and there is something else that needs to be done that is new to me ( not used Unity outside of compute shader tests since before 2019). So alot of stuff is new so maybe there is something that I am missing. Edit: Nope, same memory leak error in that version too. All 5 versions now. Edit 2 : The memory leak appears to be related to the entity baking and AllocatorManager. Removed all ECS code and scene elements and sub scene. Put the single cube prefab on the screen and it runs with no problems. Add the ECS stuff back - memory errors. Although I feel better now somewhat as it seems that as recent as October last year people have been seeing the memory leak issue come up. I just don't understand why I get it and no one else here has had the problem.
@xrystal
@xrystal 11 ай бұрын
Well, after trying another tutorial with a similar example, I looked back at this one and narrowed down the only way I could get it to work. My SpawnerSystem OnUpdate ended up having this code in it before it would work. Any variation to your set up would go ignored. Spawner spawner = SystemAPI.GetSingleton(); var prefab = spawner.prefab; var qty = spawner.spawnCount; if (spawner.nextSpawnTime < SystemAPI.Time.ElapsedTime) { var instances = state.EntityManager.Instantiate(prefab, qty, Allocator.Temp); spawner.nextSpawnTime = (float)SystemAPI.Time.ElapsedTime + spawner.spawnRate; } I am not sure why the EntityCommandBuffer nor the SingletonEntity blocks of code wasn't working for me.
@Edraptor
@Edraptor 6 ай бұрын
My prefab has an animator component with 1 animation I want it to play on loop when spawns. Is there an easy way to do this?
@freedomcoding
@freedomcoding 6 ай бұрын
Hi, In the animator just connect the animation to the entry node and set the looping of the animation asset. If you want to make the object move and use DOTS, you should use the hybrid approach to move the entity, and adjust position of the animated GameObject based on it. (as I remember DOTS doesn't support animations)
@JanDevPL
@JanDevPL Жыл бұрын
Good video.
@JanDevPL
@JanDevPL Жыл бұрын
But it is to hard.
@GrayFoxware
@GrayFoxware Жыл бұрын
THanks.subscribed. I need more ecs tutorials please.
@freedomcoding
@freedomcoding Жыл бұрын
Thanks! They are coming soon :)
@DamonPowell-s5v
@DamonPowell-s5v 4 ай бұрын
Why cant tutorials be as clear as yours, this isn't just luck your just skilled somehow at making easy to understand tutorials, cause all your other tutorials make sense too
@freedomcoding
@freedomcoding 4 ай бұрын
Thank you
@이건개발-p8n
@이건개발-p8n 3 ай бұрын
쉽게 이해하였습니다.
@bishopjackson2264
@bishopjackson2264 7 ай бұрын
Hey, did I miss it or does your video not explain what the Cube.cs script does?
@freedomcoding
@freedomcoding 7 ай бұрын
Hi, I know it is a bit confusing. The Cube.cs is one of my older scripts I believe. I didn't use it in the video at all.
@bishopjackson2264
@bishopjackson2264 7 ай бұрын
@@freedomcoding Heya check out 17:27 You can see the reference to Cube.
@meatpuppet5036
@meatpuppet5036 7 ай бұрын
Im confused, where does the CubeSystem get used? Do I add it to something?
@freedomcoding
@freedomcoding 7 ай бұрын
This one runs on all of the cubes and makes them move and slow down overtime. This script is a system, meaning you don't have to add it anywhere.
@hacbit
@hacbit 8 ай бұрын
how can i tell which function can add [BurstCompile] attribute, i try to add it to OnCreate but it reports error
@freedomcoding
@freedomcoding 8 ай бұрын
What does the error say?
@hacbit
@hacbit 7 ай бұрын
@@freedomcoding i already got it🤣it seem to be caused by creating a managed type😱
@hansayasa52
@hansayasa52 8 ай бұрын
Hi thanks for the nice tutorial, my project is in the URP but i am not able to see the cubes that are spawning. Any Idea?
@hansayasa52
@hansayasa52 8 ай бұрын
Also not working on HDRP, do i have to import graphic packages or not becasue i only import Entities, Burst and Mathematics Packages
@freedomcoding
@freedomcoding 8 ай бұрын
Hi, yes importing entities graphics (I dont remember how exactly it is named) will fix the issue.
@GiMiat
@GiMiat 7 ай бұрын
I was wondering about the gameobject with the authoring script, is there any use for it after the baking? should we destroy it from the main scene? is it usefull after the baking in any other way? Thanks for the videos really usefull!
@freedomcoding
@freedomcoding 7 ай бұрын
It is just for the initial setup, so it shouldn't be needed after baking. I am glad you like them!
@LesP56
@LesP56 6 ай бұрын
Will DOTs work in any Unity project? For example, I'm starting on a multiplayer project that uses Netcode for Gameobjects. Could I use it to improve performance of that project?
@freedomcoding
@freedomcoding 6 ай бұрын
Hi, DOTS will work with any project, but it may be better suited for RTS and other games where you have tons of objects/units and calculations to make. If you want to use DOTS for multiplayer, it is surely a good idea because then you can use Netcode for Entities and have many more users be able to play the game on one server. With Netcode for GameObjects the max recommended players on one server is 16 I think.
@Amarty2030
@Amarty2030 6 ай бұрын
Great keep going
@freedomcoding
@freedomcoding 6 ай бұрын
Thanks! I will.
@mihakramberger9733
@mihakramberger9733 Жыл бұрын
Hi, following this tutorial, yes I see cubes spawning and moving, but I cannot select cube in Entities Hierarchy. Inspector window is empty if i select it
@mihakramberger9733
@mihakramberger9733 Жыл бұрын
Found the reason..... Entities package doesnt support 2023 version yet fully.
@freedomcoding
@freedomcoding Жыл бұрын
Really? Thats a shame... As I am getting more into DOTS I am finding more and more functionality that is missing and 2023 doesnt even support inspector :D
@mihakramberger9733
@mihakramberger9733 Жыл бұрын
@@freedomcoding Installing 1.2 preview version Entities solves it.
@freedomcoding
@freedomcoding Жыл бұрын
@@mihakramberger9733 Good to know!
@IndieGamesWTF
@IndieGamesWTF Ай бұрын
Is it OK that at 10:12 you are calling TryGetSingletonEntity and GetComponentRW on the OnUpdate? isn't there a way to run this thing on "init" somehow instead of running it every frame? (I'm supposing OnUpdate is working as the MonoBehaviour Update function)
@freedomcoding
@freedomcoding Ай бұрын
Yes you could definitely cache it at start. It depends on when the object will be instantiated. If it will be there from start and stay there, caching is surely a better option.
@fabienclotilde8265
@fabienclotilde8265 Жыл бұрын
HI, thanks for this tuto. I finally understood how to make DOTS work. It's not so easy as simple OOP. Anyway, I've tried changing color of the cube overtime, but I don't know how to access to the material color. If I understand well what's in the doc., I should try getting the shared component for the RenderMeshArray ! But I don't get it. Do you have any advice ? thanks
@freedomcoding
@freedomcoding Жыл бұрын
Hi, I just tried it and you can do something like this: RenderMeshArray renderArray = entityManager.GetSharedComponentManaged(entity); renderArray.Materials[0].color = new UnityEngine.Color(1, 0, 1); You just need to know on which index the material you want to set is.
@HeadPack
@HeadPack Жыл бұрын
The next Brackeys in the making.
@freedomcoding
@freedomcoding Жыл бұрын
Thanks for this huge compliment :D Everyone has a different style of tutorials, so I am glad you like mine!
@mihakramberger9733
@mihakramberger9733 Жыл бұрын
Can you maybe tell, how can object be instantiated at certain or random position, instead of just the position that is defined in prefab ?
@freedomcoding
@freedomcoding Жыл бұрын
Hi, you can use the Mathematics.Random class to achieve that. I made an enemy spawner that spawns enemies around the camera and video for that will be out today. I may also make an indepth tutorial about random in DOTS at some point.
@MohammadFaizanKhanJ
@MohammadFaizanKhanJ 10 ай бұрын
Warning! 17 Minutes tutorial will not take 17 minutes to complete. Thanks for good tutorial. Just to calirfiy you neceesarily not required HDR or URP to work with ECS.
@freedomcoding
@freedomcoding 10 ай бұрын
That is true! I think you can`t see the objects if you use built-in render pipeline but I may be wrong.
@MohammadFaizanKhanJ
@MohammadFaizanKhanJ 10 ай бұрын
@@freedomcoding you are absolutely right 👍
@mistrebrown7642
@mistrebrown7642 9 ай бұрын
12:00 , unity 2022.3.18f1, just doesn't work. Memory leak
@freedomcoding
@freedomcoding 9 ай бұрын
Does it prevent you from playing the game? How big is the leak? Does it give you any additional information about the leak?
@fokozuynen2048
@fokozuynen2048 11 ай бұрын
I am pretty sure that return; at line 15 will just stop there and no spawn.
@freedomcoding
@freedomcoding 11 ай бұрын
In cube spawner system right? I showed text in the video saying there should be "!" before the condition.
@5ive.kingdom
@5ive.kingdom 9 ай бұрын
seems like this is difficult , is it worthy to learn this because currently im applying for the jobs , so in the companies will they use DOTS or OOPs ? Im just confused whether to learn this or not
@freedomcoding
@freedomcoding 9 ай бұрын
Yes it is more difficult than OOP, but you can achieve greater things with DOTS. It depends on what type of game the company is developing. If it is some Vampire Survivors-like game where you have ton of objects/enemies/bullets then the company could be using DOTS. I think DOTS is the future of Unity, because it can hugely increase performance. So it depends on what kind of games you want to make and if you really need to get as much performance as possible.
@JanDevPL
@JanDevPL 11 ай бұрын
What is a baker?
@JanDevPL
@JanDevPL 11 ай бұрын
And what are flags?
@freedomcoding
@freedomcoding 11 ай бұрын
Baker allows you to set some data on object in inspector and bake it to entity.
@freedomcoding
@freedomcoding 11 ай бұрын
Transform usage flags define how you want to use transform of entity. If it should automatically add one or not.
@JanDevPL
@JanDevPL 11 ай бұрын
thanks@@freedomcoding
@JanDevPL
@JanDevPL 11 ай бұрын
thanks!@@freedomcoding
@chopper4402
@chopper4402 Жыл бұрын
What is this "Cube" Script?
@freedomcoding
@freedomcoding Жыл бұрын
You mean that one that you can see in my visual studio scripts? I know this can be a bit confusing. I was just doing some testing with this script. All of the scripts you need are described in the video, so you dont need to care about this one.
@Mendogology
@Mendogology Жыл бұрын
@@freedomcoding but after 14:38 you are calling component. WTF
@freedomcoding
@freedomcoding Жыл бұрын
@@Mendogology I am sorry for the confusion. I had two versions. One that I made in the video and one I made before. The Cube script is duplicate of the CubeComponent (so you can just input CubeComponent instead of Cube). Hope it now makes sense.
@UjaniRohan
@UjaniRohan 11 ай бұрын
Wow so buetifull so aligate just looking like a wow
@Mendogology
@Mendogology Жыл бұрын
So in place of showing how you write and create all the stuff in extremally fast speed, and then showing nothing and just explaining, why don't you show everything in normal speed while explaining? And what is that component you are referencing after 14:40?
@freedomcoding
@freedomcoding Жыл бұрын
Thanks for your feedback, I try to make my videos up to 20 minutes. I know this part is confusing as I didnt show what is in the other scripts. The cube script I am referencing is the same as CubeComponent.
@lordsubl1me
@lordsubl1me Ай бұрын
rust too actually. facepunch been using ecs for rust since 2019.
@freedomcoding
@freedomcoding 29 күн бұрын
That is interesting. Thanks for letting us know!
@dungphamtien3255
@dungphamtien3255 Жыл бұрын
Cảm ơn bạn hiền !
@coolman1601
@coolman1601 2 ай бұрын
great video however looping over all entity's and checking if they have a certain components seems like a really bad idea.
@freedomcoding
@freedomcoding 2 ай бұрын
Thank you. Yes, you are right. Instead you should be using the entity queries if I remember correctly.
@JanDevPL
@JanDevPL 11 ай бұрын
Can you draw and explain
@freedomcoding
@freedomcoding 11 ай бұрын
The animations take a lot of time to make :D Which part are you confused about?
@JanDevPL
@JanDevPL 11 ай бұрын
everything @freedomcoding
@fakultixr
@fakultixr 2 ай бұрын
Good tutorial..now i know..DOTS not for me
@freedomcoding
@freedomcoding 2 ай бұрын
I hope I didn't discourage you. I also haven't used DOTS in a real project yet, but it can certainly be useful when performance is critical.
@fakultixr
@fakultixr 2 ай бұрын
@@freedomcoding not at all..at least now i know what is actually DOTS is...yup aggree with you on performance critical application.
@brockoala2994
@brockoala2994 4 ай бұрын
Nice tutorial, but your accent is so hard to understand. Can you use an AI voice to make it clearer to listen to?
@freedomcoding
@freedomcoding 4 ай бұрын
Thanks, I could do that but it would not be authentic and I think it is better to listen to a real person speaking. Thanks for the suggestion though. You can always turn on the captions :)
@paperrocketeer
@paperrocketeer Жыл бұрын
Loved the tutorial, but pls, don't show your face in the video while explaining code, it is very distracting.
@freedomcoding
@freedomcoding Жыл бұрын
Thanks for your feedback! That makes sense, i will think about it and probably change it in next videos.
@TomMcDonaldGames
@TomMcDonaldGames Жыл бұрын
I didn’t mind. I actually enjoy seeing who is going over the code
@freedomcoding
@freedomcoding Жыл бұрын
@@TomMcDonaldGames Thanks for feedback! I will make it "mixed" so sometimes when I am explaining something hard, camera will be off and when I am just talking I will turn it on.
@krishx007
@krishx007 11 ай бұрын
Use YOUR OWN Script Templates In Unity! || DOTS Time Saver
4:16
Freedom Coding
Рет қаралды 991
Should You Use DOTS in 2024? (plus what is Unity ECS)
30:15
Turbo Makes Games
Рет қаралды 45 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Starting Your Unity Game Flawlessly (8 Steps)
9:51
PracticAPI
Рет қаралды 32 М.
Подробный урок по Entity Component System в Unity
15:27
Insane One - Разработка игр
Рет қаралды 45 М.
SAVE HOURS OF YOUR LIFE - Unity Netcode Tips
1:54
Lebbi
Рет қаралды 3,2 М.
Data-Oriented Input in Unity ECS - DOTS + Input System 2023
19:24
Turbo Makes Games
Рет қаралды 16 М.
Why Majora's Mask's Blue Dog Took 25 Years to Win the Race
21:04
Vidya James
Рет қаралды 2,4 МЛН
Compile Code Faster With Assembly Definitions || Unity Tutorial
9:49
Freedom Coding
Рет қаралды 1,7 М.
I built a REAL Desktop App with both Tauri and Electron
12:22
Bufferhead
Рет қаралды 91 М.