Finally a tutorial I understand. Since dots is all about separating data and objects everyone should be doing tutorials like this where you build it through code instead of converting existing game objects. 🎉
I love this tutorial! Great work. PSA for anyone using URP or HDRP, you'll need to use the RenderMeshUtility instead of AddSharedComponentData to add your rendering data: RenderMeshUtility.AddComponents(myEntity, entityManager, new RenderMeshDescription(unitMesh, unitMaterial));
believe me, I searced the whole youtube and including bilibili, this is easiest and clearest video. If there has tip functions, I absolutely will tip this professor
I wrote the code in 3:45,but in Entity Debugger "No World selected" is displayed. Color of World in "World.DefaultGameObjectInjectionWorld.EntityManager" doesn't change in VSCODE.
Those packages (Entity and Hybrid Renderer) don't show up in my package manager. I'm using Unity 2019.3.6f1. Any ideas? Could they have changed the names in the last month since this video was made?
Thanks! One question though: We specify in our archetype that we want a translation component on the entities we create from that archetype. If we then say entityManager.AddComponentData(...), don't we add a component that's already there? Shouldn't it be entityManager.SetComponentData(...)? That's at least how the documentation describes it.
Unity have hidden these packages. I just found out myself. You have to go to the Package manager click the + button at the top and select "Add package from git URL" and paste in "com.unity.entities" and after 5-10 seconds of nothing happening the package will install. Repeat again for "com.unity.rendering.hybrid". forum.unity.com/threads/visibility-changes-for-preview-packages-in-2020-1.910880/ for more info
Good stuff! Can someone help me out with documentation on what Component Types there are and which Properties they have? Docs seems to be vague about this
You're not using AddComponentData properly. Those components have already been defined by the archetype. In previous versions, this would've caused an exception to be thrown, though that function has since been changed into a sort of "safe set" where it performs a check to see if the component exists before setting the value and creates it if it doesn't. But this also means it's naturally a bit slower than SetComponentData which skips that check entirely. And lets face it, the entire point of ECS is squeezing every last drop of performance out of the engine.
Before diving too deep in this topic, I am wondering if all this could hypothetically be used for mass destruction physics. So hundreds or thousands of kinematic rigidbodies in the scene under the influence of forces. Would ECS suit something like this?
I have a problem with all this. The entities I create have the right mesh, but they appear completely black, as if they don't receive any light. Does someone have an idea?
Can't find it, was really interested in it but I enabled previews and neither of the packages showed up. Someone said that you had to install the beta version of Unity to use it?? Weren't they showing Demo's of this system like over 10 years ago? They still haven't introduced it as part of Unity yet? I tried looking under it with Show Preview Packages enabled under both 2019 and 2020 and in neither cases would it come up.
In Unity 2020, the DOTS preview packages are hidden. You have to add them either by URL (plus icon in top left) using the GitHub URL. Or just edit the manifest.json with the URL and version number; it will reload the package once that updates. Just add the HybridRenderer; the rest of the packages will come automatically because of the dependencies.
I cant use a default created 3d object or a 3dModel I created with ProBuilder as mesh, what does the mesh need that I can drag it into the spawner scripts? thx Edit: ok i found a way, i need to export the model i made with Probuilder to .obj first, then a mesh appears that i can use.
help anyone ,how does one know what are the things required to render entity, like RenderBounds. Where are these things documented, i didn't find that in ecs manual
A lot of things have pretty sparse documentation at the moment. You can find the latest documentation about the HybridRenderer here: docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/manual/index.html If you go to the Scripting API pages, you can find specific descriptions: docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/api/Unity.Rendering.RenderBounds.html But again these are pretty bare at the moment.
Draké Martinéz Yes, you definitely need some C# experience before learning DOTS. However, the advantage of starting out with it is that you don’t have to unlearn a lot of stuff. DOTS drops a lot of the object-oriented practices traditionally associated with game development in Unity
My subscenes flipout when I try do some static batching. Does DOTS not support it? I can live with that but I'd like to know if that is the thing... Can anybody help?
I don't think that works with the Hybrid Renderer. This thread may be helpful: forum.unity.com/threads/project-available-hybrid-renderer-sandbox.681142/
@@GameAcademySchool Ohhh Sweet! ~ Of course I need to watch the entire thing! this got me as this is the first video I see about the system. Thank you!
someone correct me but this only seems useful for things you generate large quantities off, perhaps dynamically. I cant see how you could build a whole world using this when you cant even see anything till runtime? EDIT: Well I see the next video goes over this issue so perhaps not but definitely seems like a lot more work
The newer workflow allows you to work with your GameObjects in the Editor and then automatically convert them to Entities at runtime. The benefits extend beyond just spawning a lot of Entities. We do that just so you can see a concrete, measurable difference in FPS. But even if you only have a few objects onscreen, the more efficient DOTS way translates into less power usage (longer battery life if you're building a mobile game, for example). Yes, it would suck if you had to script everything manually every time you make an Entity. You don't. The Editor is getting workflow improvements to make following this new architecture easier. Probably I should have started with the easier/UI way to make an Entity and show the manual, scripted way a supplementary video.
@@GameAcademySchoolis the UI way the next video in the series or is that elsewhere? also does converting a large scene of objects to entities at run-time cause extra load at run? also i imagine if you have a scene so large you need ECS then it would be hard on the editor anyway because you still have objects before run, would be great if you could cut out the middle make and interact with entities directly in editor
We cover one way using the ConvertToEntity utility in the Editor but that is the “older” way. There is something called SubScenes you can use that is more interactive. You can work with GameObjects/Entities in the Editor. You can split scenes into smaller SubScenes and work on one piece of the scene at a time. This allows for much more complex environments with more objects/Entities in your scene.
Thank you for explaining this. I'm just starting to learn about ECS after seeing the UniteLA unity MegaCity simulation video, which blew my mind. When thinking about Entities, you almost make it sound like astrophysics, and as if Entities are photons of LIGHT, with no mass, but with energy and speed and direction. Bad analogy I'm sure, but it's all I got right now. Anyway, watching more of your videos so that I can understand better. And that Entity Boilerplate does look terrifying. I start to wonder if a whole new language is going to come out of this some day... Maybe it should be called E!, since C# implies that we have reached the highest C we can have, and E stands for Energy in physics. "E=EC#" or something. I dont' know.
What the...? World.DefaultGameObjectInjectionWorld.EntityManager is even longer than the longest word in any of the major English language dictionaries (which is *pneumonoultramicroscopicsilicovolcanoconiosis* ) 🖐😮
Agreed. It used to be World.Active. But as the ConversionWorkflow was added, I think the term became inaccurate. Technically I think “DefaultGameObjectInjectionWorld” is more accurate if terrible to type. It refers to that default intermediate world used for conversion.
Well, the title suggests creating ONE Entity (an Entity - simple cube), but you are using an archetype that suggests multiple entities of the same type. Would be great to inform the watcher how to make it without an archetype.
AWESOME TUTORIAL, but... what a pain in the a** is programming in DOTS... wtf... In the moment he said "You can't manipulate an entity from the Scene view my mind deleted DOTS as a viable method. NOT ARTIST FRIENDLY!!! it is worth it if you do ALL being a programmer, but if you have multiple artists withouth knowledge of programming this is not worth it...
radenzito sorry I should have showed you guys the SubScene Conversion first. Much easier. This is for folks who want the specific steps. Anybody can convert a GameObject to Entity using the UI...
lol is anyone actually able to make anything useful or finished out of this DOTS shit? Why is everyone so obsessed with it? What even is Unity? Is it a fleshed out game engine or is it just a platform for people to make and sell "Assets" on or have a Patreon where they make tutorials? What a joke.
You're right. You can get by just fine in Unity without DOTS. It's actually quite hard to build a complete game in DOTS right now. But the industry has sort of been moving this direction for a while, so the hardware can be used more efficiently. Though it's kind of painful to go through all of these steps to do basic stuff for the moment, eventually there will be a payoff in a couple of years when the UI and feature set catches up with the underlying architecture. People are obsessed with it, because it's a bit of learning curve and we need to get ready...
@@GameAcademySchool Totally agree with you both on this. It is a PITA! It is like going back 40 years to Assembly on a 80286. DATA in one part. Code in another. Efficient. Kind of fun in a geeky way but really not an efficient or maintainable way to code. I play with it now and then (like watching this video) but assume most of this will get "wrapped" and we can use the higher-level way to code with components and still some OO. @Sparrowhawk I think when it comes to performance it is quite amazing and fits some of the paradigms the old console programmers like. PS: Thanks @Game Academy.school for making this. @Sparrowhawk thanks for speaking up about the (cute but big) "elephant in the room." :-)
Mike Croswell I think I should have started with the Conversion Workflow video. Day-to-day usage is quite a lot less work. You only need to do this “Pure ECS” approach when you need some custom tweaking.
@@GameAcademySchool Okay. I'll go check out your other video. Thanks much. For "fun", I''ll likely finish this tutorial first. FYI: I used this stuff with Zenject (sp?) last summer with a team. I did not like it at all. It reminds me of some of the old Microsoft COM OLE and even DirectX stuff where you are not actually learning science but someone's loosely collected bunch of code. It's like Unity had this shoved down their throats by someone and they don't seem to have a controlled access point. LIke 100 people were all working on creating these technologies and someone (mostly through luck!) was able to string it altogether. I mean, just look at how obfuscated it is just to create an entity. The paradigm should match Unity's normal one. You'd use attributes to mark the the data you want to parallelize like this; [DATA COMPONENT] and then do the same for the code, eg, [CODE SYSTEM]. For creating entities, they could have EntityManager have access to the World and so you should be able to just say EntityManager.CreateEntity instead of asking the World via the default mess. Really odd. Anyway, thanks for letting us bitch. :-)
@@MikeCroswell Yeah there are definitely a lot of people working on DOTS now. My guess is that they took a hard look at what they have and they have no other way forward to stay competitive. Their original architecture, while easy for users, is ultimately holding them back. It will be a painful transition that will take a couple more years I think before the new one is attractive enough to replace the "classic" one. But we'll see. I've been trying to keep an open mind about it. It's way way easier than it was a year or two ago.
Why unity bragging about ECS and efficiency, now hardware can emulate ps3 and xbox 360 games 60 games, most of them are even killzone, gears, halo ,red ded 2 still more complex than current unity best games, now hardware do not care about efficiency anymore.
All developers care about efficiency. You don't NEED to use DOTS or ECS if your game isn't high performance. But even for a simple game, efficiency means less stress on the hardware; for example, a comparable DOTS game will use less battery life on a mobile platform.
Finally a tutorial I understand. Since dots is all about separating data and objects everyone should be doing tutorials like this where you build it through code instead of converting existing game objects. 🎉
I love this tutorial! Great work. PSA for anyone using URP or HDRP, you'll need to use the RenderMeshUtility instead of AddSharedComponentData to add your rendering data:
RenderMeshUtility.AddComponents(myEntity, entityManager, new RenderMeshDescription(unitMesh, unitMaterial));
I was looking for this very answer on every possible forum about ECS in Unity, but unsuccessfully. You saved me stranger, thank you!
This comment needs to be GOATed.
@@hellsbuster RIght. One of the greatest videos and useful follow-up post!
Entity = things, Component = data, System = logic !!! Now i'm starting to understand DOTS !!! Thank you !!!😍😍😍
I like the way you explain things, it's informative and easy to understand :)
Straight forward and informative. Awesome tutorial!
Great introduction to ECS!
The best tutorial even in 2022. Thank you for your videos!
I'm not getting entity and hybrid renderer packages, I'm using 2021.3.5f1
believe me, I searced the whole youtube and including bilibili, this is easiest and clearest video. If there has tip functions, I absolutely will tip this professor
Thank you so much for the very comprehensive and efficient guide, you deserve a big chocolate cake
Finally, a great tutorial for ECS!
Superb tutorials. Clear, focussed, and professionally executed.
Very instructive. Thank you so much for taking the time to do this class.
Thank you for immediate updating contents!
Thank you so much, I'd been looking for a clear explanation of this for days now.
Best teacher in the world right here.
Many thanks for keeping this current.
unitylist.com/p/zro/Unity-DOTS-Following-Along
Great tutorials mate keep it up!
Best tutorial on the internet, thank you!
Excellent clear explanation - many thanks
It looks like the newest version has renamed Entity 0 to "World Time.' It's still Index 0, it just has a proper name. Cool.
Yeah I think that came with Entities 0.6
you are sooooooooooooooo underrated
I wrote the code in 3:45,but in Entity Debugger "No World selected" is displayed.
Color of World in "World.DefaultGameObjectInjectionWorld.EntityManager" doesn't change in VSCODE.
Could you make a prefab and spawn that instead of putting material and mesh in a spawner?
Those packages (Entity and Hybrid Renderer) don't show up in my package manager. I'm using Unity 2019.3.6f1. Any ideas? Could they have changed the names in the last month since this video was made?
Found it. In Package Manager click "advanced," then "show preview packages." Then both packages will show up.
When my rendermesh is a quad with RenderBounds the renderer doesn't render the mesh until the center point is in camera view.
If I want animation for 3d model then I just add archetype Animation and field Animation animation to Component struct ?
awesome, keep going, ur videos are really good and helpful !!
Lol, doing better lessons than Unity itself, thanks a lot
Thanks! One question though:
We specify in our archetype that we want a translation component on the entities we create from that archetype.
If we then say entityManager.AddComponentData(...), don't we add a component that's already there?
Shouldn't it be entityManager.SetComponentData(...)?
That's at least how the documentation describes it.
Yes, you are correct, it should be SetComponentData if the Entity already has the Component.
I have preview packages enabled, but Entity and Hybrid Renderer aren't available. Did the names change in the past few months?
Unity have hidden these packages. I just found out myself. You have to go to the Package manager click the + button at the top and select "Add package from git URL" and paste in "com.unity.entities" and after 5-10 seconds of nothing happening the package will install. Repeat again for "com.unity.rendering.hybrid".
forum.unity.com/threads/visibility-changes-for-preview-packages-in-2020-1.910880/ for more info
From the Package Manager window: Advanced > Show Preview Packages
@@MrKraignos I did that and it didn't work....Tried it under the 2020 and 2019 versions and couldn't find it
Good stuff! Can someone help me out with documentation on what Component Types there are and which Properties they have? Docs seems to be vague about this
i like you clearly share. very good !!
You're not using AddComponentData properly. Those components have already been defined by the archetype. In previous versions, this would've caused an exception to be thrown, though that function has since been changed into a sort of "safe set" where it performs a check to see if the component exists before setting the value and creates it if it doesn't. But this also means it's naturally a bit slower than SetComponentData which skips that check entirely. And lets face it, the entire point of ECS is squeezing every last drop of performance out of the engine.
Just get the Hybrid Renderer package, it will install the others as deps
Caleb Whitehead Yes that is a good way to make sure the versions are compatible.
current version of Unity 2019 does not include hybrid renderer
Before diving too deep in this topic, I am wondering if all this could hypothetically be used for mass destruction physics. So hundreds or thousands of kinematic rigidbodies in the scene under the influence of forces. Would ECS suit something like this?
Andorf The White Yes, if you wanted robust physics, DOTS and the new Unity Physics framework (or Havok framework) is what you want to use.
@@GameAcademySchool Thanks for the quick reply!
I have a problem with all this. The entities I create have the right mesh, but they appear completely black, as if they don't receive any light. Does someone have an idea?
How come my script isn't recognizing "Translations"? I am using unity.Transforms, but I dont know.
I have the things installed for it from the package manager but for some reason, unity doesn't recognize "using Unity.Entities;" and I don't know why?
Check if you conflicting versions of the necessary packages. Look at the dependencies next to Entities and Hybrid Renderer
@@GameAcademySchool Thank You! One of them was on a newer version, and it also doesn't help that visual studio code doesn't recognize it :P!
Can't find it, was really interested in it but I enabled previews and neither of the packages showed up. Someone said that you had to install the beta version of Unity to use it?? Weren't they showing Demo's of this system like over 10 years ago? They still haven't introduced it as part of Unity yet? I tried looking under it with Show Preview Packages enabled under both 2019 and 2020 and in neither cases would it come up.
In Unity 2020, the DOTS preview packages are hidden. You have to add them either by URL (plus icon in top left) using the GitHub URL. Or just edit the manifest.json with the URL and version number; it will reload the package once that updates. Just add the HybridRenderer; the rest of the packages will come automatically because of the dependencies.
@@GameAcademySchool Ah alright thanks, I'm interested to see it in action.
I cant use a default created 3d object or a 3dModel I created with ProBuilder as mesh, what does the mesh need that I can drag it into the spawner scripts? thx
Edit: ok i found a way, i need to export the model i made with Probuilder to .obj first, then a mesh appears that i can use.
I hate that the rendermesh is only a shared component. Its so annoying for make procedural anything
help anyone ,how does one know what are the things required to render entity, like RenderBounds. Where are these things documented, i didn't find that in ecs manual
A lot of things have pretty sparse documentation at the moment. You can find the latest documentation about the HybridRenderer here:
docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/manual/index.html
If you go to the Scripting API pages, you can find specific descriptions:
docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/api/Unity.Rendering.RenderBounds.html
But again these are pretty bare at the moment.
I am a beginner in coding and I don't have any knowledge in it...
Do I need to learn C# before getting started with Unity DOTS...???
Draké Martinéz Yes, you definitely need some C# experience before learning DOTS. However, the advantage of starting out with it is that you don’t have to unlearn a lot of stuff. DOTS drops a lot of the object-oriented practices traditionally associated with game development in Unity
@@GameAcademySchool Thank you for your reply...🙂
Uh whats an "entity"
My subscenes flipout when I try do some static batching. Does DOTS not support it? I can live with that but I'd like to know if that is the thing... Can anybody help?
I don't think that works with the Hybrid Renderer. This thread may be helpful: forum.unity.com/threads/project-available-hybrid-renderer-sandbox.681142/
This thing is already in Cryengine since 2016
With this new system, it feels like we have to `spoonfeed` the entity it to the point we need to input everything it should use... wow...
Sorry, you don’t need to create Entities manually. Keep going in this series and you’ll see an easier way...
@@GameAcademySchool Ohhh Sweet! ~ Of course I need to watch the entire thing! this got me as this is the first video I see about the system. Thank you!
someone correct me but this only seems useful for things you generate large quantities off, perhaps dynamically. I cant see how you could build a whole world using this when you cant even see anything till runtime?
EDIT: Well I see the next video goes over this issue so perhaps not but definitely seems like a lot more work
The newer workflow allows you to work with your GameObjects in the Editor and then automatically convert them to Entities at runtime. The benefits extend beyond just spawning a lot of Entities. We do that just so you can see a concrete, measurable difference in FPS. But even if you only have a few objects onscreen, the more efficient DOTS way translates into less power usage (longer battery life if you're building a mobile game, for example).
Yes, it would suck if you had to script everything manually every time you make an Entity. You don't. The Editor is getting workflow improvements to make following this new architecture easier.
Probably I should have started with the easier/UI way to make an Entity and show the manual, scripted way a supplementary video.
@@GameAcademySchoolis the UI way the next video in the series or is that elsewhere? also does converting a large scene of objects to entities at run-time cause extra load at run? also i imagine if you have a scene so large you need ECS then it would be hard on the editor anyway because you still have objects before run, would be great if you could cut out the middle make and interact with entities directly in editor
We cover one way using the ConvertToEntity utility in the Editor but that is the “older” way. There is something called SubScenes you can use that is more interactive. You can work with GameObjects/Entities in the Editor. You can split scenes into smaller SubScenes and work on one piece of the scene at a time. This allows for much more complex environments with more objects/Entities in your scene.
Thank you for explaining this. I'm just starting to learn about ECS after seeing the UniteLA unity MegaCity simulation video, which blew my mind.
When thinking about Entities, you almost make it sound like astrophysics, and as if Entities are photons of LIGHT, with no mass, but with energy and speed and direction. Bad analogy I'm sure, but it's all I got right now. Anyway, watching more of your videos so that I can understand better. And that Entity Boilerplate does look terrifying. I start to wonder if a whole new language is going to come out of this some day... Maybe it should be called E!, since C# implies that we have reached the highest C we can have, and E stands for Energy in physics. "E=EC#" or something. I dont' know.
What the...? World.DefaultGameObjectInjectionWorld.EntityManager is even longer than the longest word in any of the major English language dictionaries (which is *pneumonoultramicroscopicsilicovolcanoconiosis* ) 🖐😮
Agreed. It used to be World.Active. But as the ConversionWorkflow was added, I think the term became inaccurate. Technically I think “DefaultGameObjectInjectionWorld” is more accurate if terrible to type. It refers to that default intermediate world used for conversion.
Well, the title suggests creating ONE Entity (an Entity - simple cube), but you are using an archetype that suggests multiple entities of the same type. Would be great to inform the watcher how to make it without an archetype.
An archetype is created to indicate which components the entity will have. If the archetype is not created, how can you add any component?
AWESOME TUTORIAL, but... what a pain in the a** is programming in DOTS... wtf... In the moment he said "You can't manipulate an entity from the Scene view my mind deleted DOTS as a viable method. NOT ARTIST FRIENDLY!!! it is worth it if you do ALL being a programmer, but if you have multiple artists withouth knowledge of programming this is not worth it...
radenzito sorry I should have showed you guys the SubScene Conversion first. Much easier. This is for folks who want the specific steps. Anybody can convert a GameObject to Entity using the UI...
lol is anyone actually able to make anything useful or finished out of this DOTS shit? Why is everyone so obsessed with it? What even is Unity? Is it a fleshed out game engine or is it just a platform for people to make and sell "Assets" on or have a Patreon where they make tutorials? What a joke.
You're right. You can get by just fine in Unity without DOTS. It's actually quite hard to build a complete game in DOTS right now.
But the industry has sort of been moving this direction for a while, so the hardware can be used more efficiently.
Though it's kind of painful to go through all of these steps to do basic stuff for the moment, eventually there will be a payoff in a couple of years when the UI and feature set catches up with the underlying architecture. People are obsessed with it, because it's a bit of learning curve and we need to get ready...
@@GameAcademySchool Totally agree with you both on this. It is a PITA! It is like going back 40 years to Assembly on a 80286. DATA in one part. Code in another. Efficient. Kind of fun in a geeky way but really not an efficient or maintainable way to code. I play with it now and then (like watching this video) but assume most of this will get "wrapped" and we can use the higher-level way to code with components and still some OO. @Sparrowhawk I think when it comes to performance it is quite amazing and fits some of the paradigms the old console programmers like.
PS: Thanks @Game Academy.school for making this. @Sparrowhawk thanks for speaking up about the (cute but big) "elephant in the room." :-)
Mike Croswell I think I should have started with the Conversion Workflow video. Day-to-day usage is quite a lot less work. You only need to do this “Pure ECS” approach when you need some custom tweaking.
@@GameAcademySchool Okay. I'll go check out your other video. Thanks much. For "fun", I''ll likely finish this tutorial first. FYI: I used this stuff with Zenject (sp?) last summer with a team. I did not like it at all. It reminds me of some of the old Microsoft COM OLE and even DirectX stuff where you are not actually learning science but someone's loosely collected bunch of code. It's like Unity had this shoved down their throats by someone and they don't seem to have a controlled access point. LIke 100 people were all working on creating these technologies and someone (mostly through luck!) was able to string it altogether. I mean, just look at how obfuscated it is just to create an entity. The paradigm should match Unity's normal one. You'd use attributes to mark the the data you want to parallelize like this; [DATA COMPONENT] and then do the same for the code, eg, [CODE SYSTEM]. For creating entities, they could have EntityManager have access to the World and so you should be able to just say EntityManager.CreateEntity instead of asking the World via the default mess. Really odd.
Anyway, thanks for letting us bitch. :-)
@@MikeCroswell Yeah there are definitely a lot of people working on DOTS now. My guess is that they took a hard look at what they have and they have no other way forward to stay competitive. Their original architecture, while easy for users, is ultimately holding them back. It will be a painful transition that will take a couple more years I think before the new one is attractive enough to replace the "classic" one. But we'll see. I've been trying to keep an open mind about it. It's way way easier than it was a year or two ago.
AWESOME TUTORIAL, but... what a pain in the a** is programming in DOTS... wtf...
Why unity bragging about ECS and efficiency, now hardware can emulate ps3 and xbox 360 games 60 games, most of them are even killzone, gears, halo ,red ded 2 still more complex than current unity best games, now hardware do not care about efficiency anymore.
All developers care about efficiency. You don't NEED to use DOTS or ECS if your game isn't high performance. But even for a simple game, efficiency means less stress on the hardware; for example, a comparable DOTS game will use less battery life on a mobile platform.