Tutorial/Discussion: Unity's New ECS (Entity Component System) - #1

  Рет қаралды 22,150

quill18creates

quill18creates

Күн бұрын

Пікірлер: 70
@quill18creates
@quill18creates 6 жыл бұрын
ARG! I forgot to add the credits properly to the video. So much fail. I don't want to take it down now that it's gone live though -- I'll make it up with something else.
@Ebonmourn
@Ebonmourn 6 жыл бұрын
i would of liked to see you actually flesh out the example of the fetching and show the difference in timing to run for each one.
@lee1davis1
@lee1davis1 6 жыл бұрын
No one has explained the differences with structs and classes as well as you just did in this video. Kudos!
@shannonrowe9402
@shannonrowe9402 6 жыл бұрын
Wow, this was exceptionally well explained. Really helped to clarify the concepts around ECS. Great stuff!
@Drecon84
@Drecon84 6 жыл бұрын
I've been looking a little bit at Data Oriented Design and I was a bit confused about how to actually apply it. This video was exactly what I needed to make the concepts useful. Thank you for a clear and concise explanation and I'm interested to see where all of this ends up going in the future.
@nikosnikolaidis3762
@nikosnikolaidis3762 6 жыл бұрын
Nice! very stoked to see ECS on this channel.
@PeppoMusic
@PeppoMusic 6 жыл бұрын
Woa that intro has way too much energy for me right after just waking up. But cool stuff! I'll look forward to you uploading more of this and will definitely watch this later. I've been looking into how to implement the ECS paradigm into my projects to improve their efficiency at a larger scale.
@hongpinglo
@hongpinglo 6 жыл бұрын
Hope part 2 out soon
@hellohaos
@hellohaos 5 жыл бұрын
Hope so =)
@theral056
@theral056 5 жыл бұрын
Any second now! I'm sure!
@shaunhall7894
@shaunhall7894 6 жыл бұрын
Very educational. The presentation from beginning to end kept me engaged. Subscribed.
@PeterF590
@PeterF590 6 жыл бұрын
Nice lecture, looking forward to your future ECS videos. Having done ECS for many years I think that the most important (and creative) part of ECS is "Dynamic behaviour composition". I.E. The WizardSystem only process entities who have a WizardComponent so when adding or removing the WizardComponent it changes the entity's to have the Wizard behaviour or not. The separation of data and behaviour also makes ECS a good candidate for server side database storage and network serialisation. Imo Unity JobSystem is an advanced optimisation topic for ECS and would be easier to grasp when one understands ECS itself. Dynamic behaviour composition gets complicated with the JobSystem because a synchronous system (aka a BarrierSystem) is needed process the async ECS command queue
@drzacha
@drzacha 6 жыл бұрын
Please, more! I love you (mainly your tutorials), and it helps me a lot.
@deusxyz
@deusxyz 5 жыл бұрын
This is a great tutorial. Reminds me of the older school days of programming in high school.
@Dragonmaster047
@Dragonmaster047 6 жыл бұрын
I strongly disagree with the struct are 99.9% like classes in C# statement. In C++, ok only difference is the default member visibility, I'd give you that. But in C# there are so many cases where just changing struct to class or vica versa breaks the whole algorithm/program. You should probably make it clear that the "structs are just values" sentiment only holds as long as you're using plain structs (not implementing interfaces) with just ValueType members and only if you keep them in variables that do not get autoboxed. Otherwise people will find them self in a world of hurt when they realise the difference between class and struct is not just pass by value/pass by reference! Other than that love your videos keep it up :)
@Hoffmanpack
@Hoffmanpack 6 жыл бұрын
Dragonmaster047 idk wtf u just said I'm worries now
@G4M5T3R
@G4M5T3R 6 жыл бұрын
Randy Hoffman TL:DR struct != class unless in C++ (but not really, but close enough)
@theral056
@theral056 6 жыл бұрын
So stoked for an intro to ECS! Amazing
@purpl3grape
@purpl3grape 6 жыл бұрын
I was thinking about how in a way, the Universe calculates it's 'entities'. In some ways, it's a bit like ECS where how it just acts on what forces it needs to, and the macro result precipitates from the culmination of all the micro calculations.
@TheBelrick
@TheBelrick 6 жыл бұрын
Quill you could be a uni lecturer you are so good at explaining this.
@Nightlurk
@Nightlurk 6 жыл бұрын
20 years later, people learn how to program the way people were programming before people learned how to program OOP...
@mdo
@mdo 6 жыл бұрын
This statement is annoyingly accurate.
@Nightlurk
@Nightlurk 6 жыл бұрын
:) este
@Sylfa
@Sylfa 6 жыл бұрын
Sure, but 1 year after that this new thing is on the rise, Object Oriented Programming, its really sweet. (This swing back and forth has happened before and will happen again, its nothing new)
@deusxyz
@deusxyz 5 жыл бұрын
xD
@jussivalter
@jussivalter 5 жыл бұрын
partically right. But ECS is not that old architectural style (maybe a bit over a ten year old??). And ECS isn't actually programming paradigm as OOP is. And in terms of paradigms, I think that old paradigms like procedural or functional are the ways people tend to code mostly before OOP. Also ECS was/is mainly used for game development.
@piotrszuflicki1527
@piotrszuflicki1527 6 жыл бұрын
Will you create the tutorial of Pure ECS?
@codingTheFuture
@codingTheFuture 6 жыл бұрын
Great video! Do you plan on do one of your game making series using ECS with the C# job system?
@mcgeufer
@mcgeufer 6 жыл бұрын
And now for something completely different: Would you mind to do a RPG-Stat system with an ECS approach? I kinda wonder how the would work. Like how to gouvern different bonuses on stats and so on. Edit: I'm on it and it turns out the whole thing is less complicated then expected.
@SoloparafocasxD
@SoloparafocasxD 6 жыл бұрын
I was wondering if I want to implement a kind of search algorithm for my array struct, could that have a negative impact in terms of performance?
@Sylfa
@Sylfa 6 жыл бұрын
Technically they don't use "bool[] alive" in ECS but rather have a "int alive" that keeps track of how many of the items are alive, then to kill an item you do: data[i] = data[alive-1]; alive -= 1; This way you skip the unsafe stack push and save an array lookup on every iteration.
@theonewhohonks9675
@theonewhohonks9675 6 жыл бұрын
Hey quill, if you still have the files from this, could you add a deltatime measurement to calculate the difference in time between the two styles? That seems like it'd help quantify the difference between the two.
@shmafoo
@shmafoo 6 жыл бұрын
Hey quill, did some reading of tutorials and example code, watched other videos regarding ECS & the job system. I have yet to write such code myself but just from reading it feels somehow more natural and logical to do it this way. Also it might actually result in not having two systems one usually needs and I wanted to know if you can confirm it at this point or what your view on this is: As this whole thing is data driven, the need for a classic event system (like you have shown in the other tutorial videos) or object pool managers is not there. Instead of creating an event and have some other object listen to it, simply create data and the rest will happen automatically due to the systems checking for existing data all the time. Also, as the data is stored in a continuous chunk of memory all the time, the thing with the object pools is obsolete as it's kind of part of the whole thing incidentally. At least if full ECS only is used and not hybrid ECS. Can this be viewed as correct or can you please share your thoughts on this? Thanks! :) /Edit: Also I think it might be even faster to write the code in the end, once you got a hang of it.
@ThoughtExperiment
@ThoughtExperiment 6 жыл бұрын
Hey Quill18, any update on the other parts of this?
@amber9040
@amber9040 5 жыл бұрын
Is ECS really mostly about performance though?
@ozgurakpinar_gr
@ozgurakpinar_gr 5 жыл бұрын
Not really. It is very helpful for "separation of concerns" (not in class level but in system level) and overall architectural design (of your game) is more closer to software development best practices.
@henrikse55
@henrikse55 6 жыл бұрын
Please correct me if I'm wrong but aren't everything references by default in C#? As far as I understand in C# everything is a reference, you are by default never working with pointers as they are not safe in itself and to my understanding to use actual pointers you are required to use enable "allow unsafe code" and encapsulate your code with the unsafe keyword.
@JordanSwapp
@JordanSwapp 6 жыл бұрын
henrikse55 you're correct, not the same thing, though similar in concept wrapped in some protective love because of the CLR. Pointers are to a memory address and not type safe generally speaking. In c# a reference points to an object, the reference can be moved in memory (garbage collector, sizing of arrays without using fixed) and the type is guaranteed and validated with the exception of using the unsafe keyword.
@JordanSwapp
@JordanSwapp 6 жыл бұрын
To address "everything references by default" is actually not true, parameters are passed by value with respect to reference type parameters they are reference types. This is why keywords like out/ref exist.
@quill18
@quill18 6 жыл бұрын
Not everything is a reference -- that's why I talked about Value types (which are not references). As for pointers: I use the word pointer here because it helps to emphasize that reference types are "pointing" to some randomly assigned memory in the heap. Mechanically, references and pointers work differently (and C# uses reference types), but in practical terms for this discussion the difference is moot.
@filipsalen2561
@filipsalen2561 6 жыл бұрын
At 5:40 he say that doing 4 things in 4 threads are faster then doing 4 things in 1 thread. Why is that? Or have I missed something imprtant? :)
@anarchoyeasty3908
@anarchoyeasty3908 6 жыл бұрын
Lets say every task takes 20ms to complete. If you have them all in 1 thread you have to wait for each one to finish before kicking off the next task. Thus all 4 tasks will take 80ms total to complete. However, if you split up those same 4 tasks into 4 different threads, that means that the tasks can be done at the same time. Thus it will only take 20ms to complete all 4 tasks.
@filipsalen2561
@filipsalen2561 6 жыл бұрын
Thanks for the answer, Ah I was thinking of a single core processor
@anarchoyeasty3908
@anarchoyeasty3908 6 жыл бұрын
It's actually still the case even on a single core processor. Modern processors all have tons of threads on them, allowing for parallel processing on a single core. If a single thread takes up all the resources then the other tasks won't happen an exactly the same time, but it will try it's best to do more than one thing at once.
@gpcm9226
@gpcm9226 6 жыл бұрын
First, thanks for the educational video. But, the scrolling up and down is hell. If you can figure out a way to keep all the lines you are talking about (seems like about 50) on-screen while you are talking about them it would help a LOT. Ideas...most monitors are quite wide so the // text can be kept in a single line. Idea...I can go to full screen mode so a smaller font can be used and it's still very legible. Thanks again
@play4fun599
@play4fun599 6 жыл бұрын
Can I still use the old component system?
@dartimosthatsit6001
@dartimosthatsit6001 6 жыл бұрын
From what Ive seen so far, it will take some coding to opt into this. You will need to specifically tell Unity to use the code for the system.
@mdo
@mdo 6 жыл бұрын
Play4Fun yes. ECS is still in preview. It doesn't even get loaded as a default package when creating a new project. You have to go out of your way to turn it on. You can even use ECS with existing component system. It's called hybrid ECS.
@jon_do
@jon_do 6 жыл бұрын
Thanks, Quill. You rock!
@lhorbrum1818
@lhorbrum1818 6 жыл бұрын
Thank you for this.
@easyBob100
@easyBob100 6 жыл бұрын
Read "Digital Design and Computer Architecture" if you reeeeeeeeeally wanna know how it works. It even has code examples for FPGAs if you're into that. Build your own lil cpu.
@MrTastelessVideos
@MrTastelessVideos 6 жыл бұрын
Just a random thought: wouldn't using Lua also make a huge performance boost? Like; what you covered in the last example part could easily be made in Lua, as far as I am aware. Using Tables and maybe managing Memory-Allocation by hand (by setting unused vars as nil, or flagging and then reusing them) would probably boost a) compilation time (or rather processing time) and b) memory usage and management, wouldn't it? Sry if I'm wrong somewhere, haven't coded proberly in like over a year now *sigh*
@Norbingel
@Norbingel 6 жыл бұрын
I just wanted to learn how to do Unity's rollerball tutorial using ECS... ;D
@adhochero6619
@adhochero6619 5 жыл бұрын
yeah, this. an example of how to actually build something and see how it all works together would be beneficial
@lamkasdev9983
@lamkasdev9983 6 жыл бұрын
Every video on start I hear "Hey fox quality here!" xD
@DJRUDONE
@DJRUDONE 4 жыл бұрын
Almost two years later and this is still not continued. But I think Quill has given up on programming :(
@shinevisionsv
@shinevisionsv 6 жыл бұрын
Awesome!
@nahco3994
@nahco3994 6 жыл бұрын
In my (limited) experience with the MVC-model, *absolutely none* of the examples available on the internet *really* conform to all those nice, simple, and abstract descriptions of the theoretical model. Add to that the fact that in more than enough cases those nice, simple, and abstract descriptions contradict each other, and you might just get the impression that absolutely nobody *really* seems to know what MVC is all about. It honestly drove me nuts when I tried researching this model for one of my assignments. Some of the best advice I eventually got went kinda like this: "It's an archaic model developed specifically for some 70s hardware. Don't even try to follow it to the letter. Nevertheless, the underlying principle is still very useful for organizing your code. Try to see the bigger picture in there, and forget about the rest."
@andrewzuo86
@andrewzuo86 6 жыл бұрын
ECS isn't just about CPU cache. It also allows super fast instantiation time.
@mcgeufer
@mcgeufer 6 жыл бұрын
Well... We got the bad and we got the good. But where is the ugly?
@Hoffmanpack
@Hoffmanpack 6 жыл бұрын
Just saying get component rigid body is obsolete took me fucking 4 hours to get it right... Fucking 4 yr old tutorials sup quill love ur tutorial s!!!
@MikoGot
@MikoGot 6 жыл бұрын
Yey!
@santoshparihar6820
@santoshparihar6820 6 жыл бұрын
Sir please make a video on using Facebook sdk or api in our game...how to play online with our Facebook friends. Please please ASAP
@totlyepic
@totlyepic 6 жыл бұрын
"The CPU can only work on data in its cache" - Caches don't have to exist. The CPU can only work on data in its registers. Doesn't affect the point you were going for, but it's not technically correct. That said, with basically any modern CPU, it's a moot point. The CPU's only pulling from memory on a cache miss.
@PHPLanceRU
@PHPLanceRU 6 жыл бұрын
Не могу воспринимать его уроки, дёрганные какие-то :)
@johnjonjhonjonathanjohnson3559
@johnjonjhonjonathanjohnson3559 6 жыл бұрын
make a better ecs than unity and laugh at them
@gregoryfenn1462
@gregoryfenn1462 6 жыл бұрын
It's a little hard to focus on a video where there is so much talking over a boring slide; something like pictures to illustrate what you're talking about, or pop-up bubbles of relevant thoughts or observations, would help me as a viewer. Your content is good but your pedagogic style is jarring, which is something I wouldn't expect for a channel with 133k subscribers.
@gregoryfenn1462
@gregoryfenn1462 6 жыл бұрын
It gets much better after 11:00. But to clarify my criticism, for a semi-formal lecture about the theory behind ECS, or the programming paradigm and computational principles of it, I would have strongly prefered to see you draw-out some thoughts and diagrams on a physical blackboard, without even touching a computer.
Unity Tutorial: Callbacks and a (Really Awesome!) Event System
1:15:27
quill18creates
Рет қаралды 40 М.
Entity Component System (ECS) - Definition and Simple Implementation
28:02
Wednesday VS Enid: Who is The Best Mommy? #shorts
0:14
Troom Oki Toki
Рет қаралды 50 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
INSANE shooter with WAY too many bullets (Unity ECS Tutorial) - PART 1
15:20
Sasquatch B Studios
Рет қаралды 12 М.
Entity Component System #1
44:33
Rez Bot
Рет қаралды 37 М.
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 767 М.
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 899 М.
Unite Austin 2017 - Game Architecture with Scriptable Objects
1:04:29
PuckMan - A Unity Tutorial for Complete Beginners - Part 1
2:39:17
quill18creates
Рет қаралды 14 М.
Rock Band: How a Genre Died in 5 Years
14:00
Extra Credits
Рет қаралды 321 М.
Unity ECS: Pure vs Hybrid (walkthrough)
18:56
Infallible Code
Рет қаралды 74 М.
Intro to Data Oriented Design for Games
52:35
Nic Barker
Рет қаралды 37 М.