How I Structure Entities In My Own C++ Game Engine

  Переглядів 9,852

FuniGameDev

FuniGameDev

День тому

How do you structure a game engine? That's one of the first questions we as game developers have. Hopefully you'll find this video informative and maybe a bit helpful too.
ENTT C++ ECS: github.com/skypjack/entt
00:00 Intro
00:06 Entity inheritance
01:25 Entity Component System

КОМЕНТАРІ: 13
@jchaloupka007
@jchaloupka007 2 місяці тому
Krásná práce! Composition over inheritance can be applied in all sorts of fields in programming, but explaining it through game dev makes it really easy and intuitive to follow and understand, you did an awesome job!
@funigamedev
@funigamedev 2 місяці тому
Díky moc! I'm so happy you enjoyed it, composition over inheritance is exactly what I was aiming for so I'm glad it made sense. Thank you for your feedback!
@harywhiteproductions
@harywhiteproductions 2 місяці тому
Great video and solution! I'm also writing a game engine in C++ and have been tackling a similar problem. In my one, each entity has an array of component indexes where each index in the array represents a component ID. If an entity doesn't have a certain component, the component index is just set to -1. The systems iterate through the entity IDs they are interested in and they access the component data through that.
@funigamedev
@funigamedev 2 місяці тому
Thank you so much! Your solution sounds great too! It's great to hear different solutions to these problems and to see that I'm not the only one dealing with this :D
@lehisluguer9300
@lehisluguer9300 Місяць тому
awesome video.. i love it.. but, even if ECS is super efficient and optimal.. wouldn't it be super confusing in the future?? when you have a loot of stuff your videogames?
@funigamedev
@funigamedev Місяць тому
Thank you so much! You're correct that this approach will need further work to make it easier to work with, for now this is sufficient enough, but I'm already working on something better and easier to use. I don't want to introduce unnecessary complexity in the whole system since ECS is still new to me and C++ as a whole is really new, but I believe in the future there will definitely be a video on how I made it easier to work with.
@BigJMC
@BigJMC Місяць тому
That’s when you make a behaviour component that holds a ptr to a scriptable object which can be used as a base class for custom behaviour. That way you can create as many scripts as you like without there being too many components.
@Utmanarn
@Utmanarn 3 місяці тому
Interesting, I have stumbled upon the problem before where I have tried to make things abstract and follow proper inheritance. But sometimes it just falls flat when my entities suddenly need to have many different variables and functions from one another. It ends up with my base entity only having like 1 or two variables...
@funigamedev
@funigamedev 3 місяці тому
Thank you! I'm glad I'm not alone, thankfully many much smarter people than me have figured out the way already :D
@joedartonthefenderbass
@joedartonthefenderbass Місяць тому
Great video! I think the component mask could be a little faster if you used a bitset instead of an unordered map but I may be wrong
@funigamedev
@funigamedev Місяць тому
Thank you for the tip! I'll definitely look into that, you might be right that it's faster, I'm still kind of searching for some better way to map and keep track of the entity component relationship, since maybe I want one entity to have more than one mesh and for that the current system isn't enough.
@69k_gold
@69k_gold 2 місяці тому
I'm a beginner, and the video went really really fast. Can you storyboard more and make your future videos longer, taking time explaining stuff one at a time?
@funigamedev
@funigamedev 2 місяці тому
I'll try to look into that, thank you for your feedback!
Coding basic Entity Component System but I am dumb. Game Engine ep. #3
13:58
So I Made My Own Game Engine...
10:19
Chadderbox
Переглядів 81 тис.
маленький брат прыгает в бассейн
00:15
GL Show Russian
Переглядів 3,7 млн
Bob Nystrom - Is There More to Game Architecture than ECS?
23:06
Roguelike Celebration
Переглядів 187 тис.
15 Years Writing C++ - Advice for new programmers
4:04
SyncMain
Переглядів 1 млн
Unix Domain Socket in 100 seconds
1:41
nixhero
Переглядів 50 тис.
Learning C++ by making a Game... in 1 Week?!
10:14
Floky
Переглядів 304 тис.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Переглядів 172 тис.
When Optimisations Work, But for the Wrong Reasons
22:19
SimonDev
Переглядів 764 тис.
Why i think C++ is better than rust
32:48
ThePrimeTime
Переглядів 259 тис.
Signals. I spent 2 years to understand this part.
21:24
kimylamp
Переглядів 108 тис.
I Rewrote This Entire Main File // Code Review
16:08
The Cherno
Переглядів 85 тис.
Learning C++ Game Engine Development in 1 Year
7:57
MakerJSON
Переглядів 11 тис.
Мужчина перехитрил вора😳
0:58
Kino_sh
Переглядів 2 млн
Все сделали сальто😳
0:31
WORLD TOP
Переглядів 14 млн