- I have done various gamedev jobs over the years, the most recent being gameplay programming for this minigame in PUBG: https://www.youtube.com/watch?v=tSP5P0QGWa4 I managed to successfully invest my savings too which let me focus entirely on Hypersomnia.
- Yes, I'd love to release on Steam before 2024.
- For now there is no persistent world at all, I just mentioned it as a teaser for where the game might be heading if it becomes successful.
- Rebuilding the physics should not at all shift positions. What is rebuilt is merely the "hot state" like contacts and trees - the only moment where hot state matters is during the process of advancing the simulation from one state to the next, it does not influence how state is later rendered etc.
The only impact on the existing players could be a single framerate drop in case the physics world to be rebuilt is massive, but in practice all our maps are still rather small, best suited for 3v3 matches.
Love to hear it! Sorry about the MacOS incident, I haven't launched it in ages as we play on Windows and Linux pretty much 100% of the time, I'll see what I can do to fix it :)
Pfft! No apologies necessary. I think I speak for everyone with a pulse and more than 2 tired but functioning brain cells when I say: thanks for supporting MacOS in the first place, cheers for your absolute galaxybrain efforts.
Hey there, a little clarification - I don't claim that I came up with ECS itself, only a particular implementation of it that is very memory efficient, and Unity's patent concerns a specific implementation as well - sorry if that was a bit misleading. As for the title, I just couldn't resist making the pun, maybe you're right though that the packer should be talked about separately.
Am I crazy or is your approach to ECS similar to a data oriented ECS?
In a fully, brutally data-oriented ECS, you would allocate all components of the same type in the same memory block, so you'd effectively end up with a std::vector<TransformComponent> and a std::vector<PhysicsComponent>, etc.
Each entity then holds ids, such as a pair of `what` component and `index` into the respective vector.
This ensures that, like your approach, the cache is used well, and that memory fragmentation is minimal.
I find your project(s) very, very inspiring as I love working on similar problems among others (github.com/lionkor), thank you for sharing!
Thank you! The approach you describe is indeed the "final form" of a brutally data-oriented ECS, but my method is a bit simpler - e.g. if the game has:
struct player {
components::transform transform;
components::health health;
};
Then my ECS simply holds a std::vector<player> and a std::vector<box> rather than having a vector per each type of component. I also use the integer identifiers like you describe but with a twist - there is one more indirection involved so that deleting from the vectors does not invalidate existing indices pointing to vector elements. It's still exactly O(1). See the section on the Memory pool in the game repo's README.
This is pretty much how games outside of general purpose engines have always done it. With some exciting variations like having one monster struct that has every property for every entity in the game so you just have a single array of entities. Or having each struct contain an ID field so you can pass around pointers and cast them based on the ID value.
Indeed, such a rigid struct-based "ECS" is basically how most non-ECS games do it, but using components to compose game objects, if you say put them into std::tuple, makes it easy to to later call e.g. a generic lambda only on vectors of objects that contain given components. This makes for an excellent statically polymorphic code that doesn't care about what particular type the game object might have (is it a character? is it a tree?) as long as it has e.g. physics + health. In my 2013 article I also describe how to apply the same concept if we don't hardcode a specific collection of "structs of components", but add/remove components to entities at runtime.
Yeah this is the nice thing about writing a game without a general purpose game engine, you only need to go as deep into these things as the game needs. Spend a lot of time with general purpose engines and it’s always a bit of a pain when their world representation is a little bit ‘wrong’ for your game.
This isn’t as ‘brutal’ as you can go because the point of data oriented programming is to organise data coherently in memory based on how it’s accessed. Linear arrays as blobs of data are fine if you have strictly linear access, but you can go further by considering how systems access data. So you end up with ideas like archetypes as ways to structure memory to minimise cache misses.
Thank you! That's interesting, I did write an article on SE about ECS back in 2013, but I think it's the first I ever published a proper piece on networking - I do link to an important Glenn Fiedler's blogpost when describing my deterministic architecture in README but just in case I'm not him, I hope I wasn't too misleading :)
- I have done various gamedev jobs over the years, the most recent being gameplay programming for this minigame in PUBG: https://www.youtube.com/watch?v=tSP5P0QGWa4 I managed to successfully invest my savings too which let me focus entirely on Hypersomnia.
- Yes, I'd love to release on Steam before 2024.
- For now there is no persistent world at all, I just mentioned it as a teaser for where the game might be heading if it becomes successful.
- Rebuilding the physics should not at all shift positions. What is rebuilt is merely the "hot state" like contacts and trees - the only moment where hot state matters is during the process of advancing the simulation from one state to the next, it does not influence how state is later rendered etc. The only impact on the existing players could be a single framerate drop in case the physics world to be rebuilt is massive, but in practice all our maps are still rather small, best suited for 3v3 matches.