Тёмный

Making an Entity Component System for my game engine 

cient
Подписаться 2,4 тыс.
Просмотров 16 тыс.
50% 1

Опубликовано:

 

28 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 49   
@lufsss_
@lufsss_ 3 месяца назад
Such a great video format, thank you for finally making me understand what ECS is
@seoulpeterson432
@seoulpeterson432 3 месяца назад
This feels a lot like a database. Obviously there's some more nuance to it than just that, but you essentially build out your columns (components), and then use your primary ID to determine the value of each component. It's simple, and straightforward, good job.
@cient_dev
@cient_dev 3 месяца назад
Never really thought of it like that before, using a composite key of components to represent an entity is a neat way of looking at it!
@insu_na
@insu_na 2 месяца назад
reinventing the wheel ftw! totally not an inner platform
@hedlund
@hedlund 3 месяца назад
stb, eh? Oh, sweet nothings, etc :) Dude deserves a damn mention in std or the spec itself at this point.
@cient_dev
@cient_dev 3 месяца назад
The guy is a legend in my books
@kinsukaweerasooriya2933
@kinsukaweerasooriya2933 2 месяца назад
Wow this is what using in Playcanvas game engine ❤
@Dougie-
@Dougie- 2 месяца назад
What's the benefits of storing the data in separate lists when all lists contains data for all entities instead of baking it all into one entity struct? Like the Move function. Why read physics and transform from their lists when they just be part of the entity itself?
@cient_dev
@cient_dev 2 месяца назад
Doing this means every entity would need every component in the entity struct, even if they don't use said component, which would become a memory burden as more and more components get added. There are ways to instead have one massive list which contains every component, laid out in a specific order for the fastest possible traversal, but it's pretty complex and honestly I don't think I need that level of efficiency for a basic ECS. This is just my compromise between ease of use and speed.
@chudchadanstud
@chudchadanstud 2 месяца назад
2:27 You're not using the dx, dy parameters
@nicdepp
@nicdepp 4 месяца назад
I really appreciate the way you explained this, somehow it hadn't really clicked before
@ygypt
@ygypt 3 месяца назад
its a shame that most people who talk about ecs talk about caching performance. unless youre making a AAA game, caching will not help you. it didnt matter when you were using oop in unity, it wont help you now XD. but omg ecs makes so many headaches go away its brilliant
@cient_dev
@cient_dev 3 месяца назад
I agree. I'm working on a video to solve a couple of the problems that remain in this implementation, but at the end of the day, I'm not out to beat EnTT or DOTS; I just want to make a decent ECS for my game
@markiel55
@markiel55 4 месяца назад
Nice format - short and contains enough info. Me like it.
@cient_dev
@cient_dev 4 месяца назад
Thank you! Appreciate it :)
@ByteSz_
@ByteSz_ 3 месяца назад
Very good video! Really thought the visuals, diagrams, and editing helped succinctly give a good idea of what an ECS is for those unfamiliar. Just wanted to clarify one thing for others and the future. Data Oriented Design is not actually packing data close together, keeping objects in memory linearly is tight packing and linear memory iteration/access. Data Oriented Design is the concept/practice of keeping all data isolated in objects, without any logic, and having functions (usually global functions) operate directly on that data from other sections of code.
@cient_dev
@cient_dev 3 месяца назад
Thank you! :) I just did a quick search and the definition seems muddy, from what I understand Data oriented Design is designing for cache friendliness, while Data Oriented Programming is what you described. I could be wrong though
@angelocarantino4803
@angelocarantino4803 Месяц назад
​@@cient_devthe term your looking for and that are describing is data locality
@angelocarantino4803
@angelocarantino4803 Месяц назад
Yep, this is correct
@techpriest4787
@techpriest4787 3 месяца назад
Have you ever considered nodes instead of components? I am working on a Prefabs Nodes Systems (PNS) kernel because I did not like how loose components are in ECS. Yes that is the entire idea in ECS. But you can only decouple the data and not the behavior in the first place. So what is the point? You are confusing yourself because "data does not show the way" anymore. That is not even data oriented design anymore either. You are limited to one component type per entity too. This makes it impossible to design an entire prefab. ECS makes lasagna code. Code that is too loose. Systems are important though. They do fetch data bunches without needing a handle. They do multi threading. They are handy for adding plugins to the base application too. That is why my own kernel is from ground up plugin based too via systems. Bevy oddly does not force plugins. And obviously plugins can be static too. Which makes me wonder why Bevy is so crude with it. You want to be flexible? Well. Use plugins too. So. Frankly. The only good things about ECS is the Systems and plugins part? And not the rest!? So make a hybrid and make handles great again with nodes? Oh. Since I code with Rust. That of course means no inheritance. Just for the record... The node handles are index based and do not hold a pointer. An entity handle in Bevy is just a single index to an entity too. Though in PNS because of the prefabs part it seems I am forced to add another index for the prefabs instance. But I am still researching. I wonder if there would be more than 256 prefabs for a single application. Because that would mean I can get away with a small u8 index. Other kernels use handle systems that require some kind of version so that a deleted data is not confused with a new one that is on the same spot so using the same index. But the prefabs part of the PNS should actually fix this and not need the versioning at all. Because the nested prefabs can be statically nested or dynamically nested. Meaning any static sub member is also spawned keeping the handles with a valid index in their respective usage context.
@erroneum
@erroneum 3 месяца назад
"But what if I want a weapon that behaves like both a sword and a bow? It can't derive from both..." C++: "Are you sure about that?" Truth be told, C++ does allow multiple inheritance, and has even solved the diamond problem via virtual inheritance; if a class B inherits from class A virtually, then rather than including an A inside B, it includes just a pointer to an A inside B, allowing multiple parent objects to all inherit from a common grandparent (or even higher) and still only have one of the object within them.
@cient_dev
@cient_dev 3 месяца назад
Honestly, I sorta regret the example I provide of the downfalls of inheritance; I think there's better ways to show why composition is (generally) more pleasant to work with and saying "Can't derive from both" is misleading, but it can get messy and you do have to have to know what you're doing (Multiple inheritance can easily become a smell) The bottom line is; I think it's easier to scale than OOP. I could be wrong though, don't forget you're talking to a guy that hasn't made a full scale game with both and this is my first rodeo. I'm planning on making a postmortem video when the project is done though to see if ECS and all the other decisions I made through the series were the right ones
@hectormejia499
@hectormejia499 3 месяца назад
you sir, have a new fan!
@ArThur_hara
@ArThur_hara 10 дней назад
I need to know what VS Theme you are using :/ (plz)
@NStripleseven
@NStripleseven 3 месяца назад
So, the Rust trait system.
@Goalatio
@Goalatio 3 месяца назад
To a point, but components are basically just tag structs that may or may not contain data. The system portion can then very efficiently find entities that match component queries (sword, iron, long) etc and handle the component data and entity they belong to. It’s a really cool system to work with BUT it can get really messy when everything in your game uses it.
@msmeraglia
@msmeraglia 2 месяца назад
not so much, Traits are functions that will still use a vtable to determine the "derived" type that is calling the function, so not much different from OO. ECS is meant to be used for splitting out your data so you group like-data elements in arrays or collections that can be iterated over contiguously in memory (cache-friendly)
@solidnywonsz
@solidnywonsz 2 месяца назад
what's the game in background?
@TheTmLev
@TheTmLev 2 месяца назад
`virtual ~IComponentPool() = default;` is a bit better than `{}` due to how compilers might look at this line of code
@cient_dev
@cient_dev 2 месяца назад
Good catch, was using it to log deconstruction during debugging but I honestly didn't know there was a difference, thank you!
@denovodavid
@denovodavid 3 месяца назад
yeah i'll sub. I like that your ECS is keeping relatively simple, but I would be wary about the unvetted benefits of _decoupling_ and _reusability_ in your early stage project.
@jwjbadger7261
@jwjbadger7261 3 месяца назад
Very well said and very high quality looking forward to your growth
@joshuathomasbird
@joshuathomasbird 2 месяца назад
just use rust traits
@ilovehumongoushonkers
@ilovehumongoushonkers 2 месяца назад
is that shapez music
@cient_dev
@cient_dev 2 месяца назад
Yessir
@Veeq7
@Veeq7 3 месяца назад
Hey, do you have a discord and github link somewhere? :)
@cient_dev
@cient_dev 3 месяца назад
I don't have a discord (maybe in the future when the game develops more!) but I have some public projects like my latest video on my Github at github.com/chrischristakis
@Veeq7
@Veeq7 3 месяца назад
@@cient_dev Awesome, thanks. and keep up the good work!
@_caracalla_
@_caracalla_ 3 месяца назад
excellent! you got a sub dude
@phoenixstyle
@phoenixstyle 2 месяца назад
Omg I love that you jhsd the music from the shapez ost! One of my favorite osts
@ryanlockhart5328
@ryanlockhart5328 2 месяца назад
Bro forgot he was using C++ which has multiple inheritance lmao
@lorenzvo5284
@lorenzvo5284 3 месяца назад
0:04 lmao
@kira.herself
@kira.herself 3 месяца назад
I love ECS give me more I beg grrr
@cient_dev
@cient_dev 3 месяца назад
The ECS is keeping itself relevant in development (for better or worse) so expect more about it next dev log :)
@poteznydominator5134
@poteznydominator5134 4 месяца назад
Nice! Bro what is the name of your editor theme?
@cient_dev
@cient_dev 4 месяца назад
Github dark default on Visual Studio :)
@HobokerDev
@HobokerDev 3 месяца назад
Classic. Step 1. Provide the shittiest most contrived example of inheritance. Step 2. Mention Cache exists Step 3. Don't show any of the actual implementation Step 4. ??? Step 5. Profit It's like those devlogs are made in a factory. Always exactly the same. This doesn't even solve any problem. Just a knee jerk reaction to add ECS because internet said ECS = good
@cient_dev
@cient_dev 3 месяца назад
Wanting to use ECS to learn about it in a game that'll almost certainly benefit from it isn't a knee jerk reaction. Also it's a dev log meant to document progress and rationale, not a tutorial. There's plenty of resources online for that already.
Далее
Barno
00:22
Просмотров 701 тыс.
CORTE DE CABELO RADICAL
00:59
Просмотров 2,2 млн
It's Hard To Make Games
18:01
Просмотров 250 тыс.
The ECS Architecture - Performance in UE4
16:28
Просмотров 20 тыс.
fixing my old game engine that apparently doesn't work
13:56
I Optimised My Game Engine Up To 12000 FPS
11:58
Просмотров 679 тыс.
Building a fast ECS on top of a slow ECS
8:03
Просмотров 30 тыс.