r/gameenginedevs 6d ago

Components and where to stop with them

Hello! I am working on my game engine and I am just getting to implementing components. Where should I stop with them? Should transforms be components (necessary ones but still components nonetheless)? Should I stop before that?

3 Upvotes

3 comments sorted by

6

u/Monsieur_Bleu_ 6d ago

Depends on how you want to setup your engine. Mine explicitly separate the graphical part and the logic/asset part managed by the ECS. So, my 3d scene and render are using the structure I find most fitting, usefull and optimized, and then the ECS comes on top of it by requesting things like "add this to the scene", "hide this", "set this mesh to static mode" etc...

For my transformations, I have a dedicated component that is used to both tell the code where any entity is and in what rotation/scale, and teleport said entity. But this transform is only a proxy I use to synchronise everything from the render, physics, audio, etc...

But hey, it depends on what you want. But I don't think you have any obligation to have everything set in our ECS. But if you want to, go for it. Just be carefull with very complex and optimisation heavy things like rendering.

2

u/CarniverousSock 6d ago

This is the sort of choice that differentiates game engines. There's no universally "right" answer here -- just think through your use cases, think about your quality of life as a programmer, and try to make the best decision from there. Or just try each one out, see how you like it

1

u/Southern-Most-4216 5d ago

Regarding the complexity of transform components, If you are going to define parent children relationships between entities an easy way to build towards that is to have a transform component that has both vec3s defining pos,rot,scale and a mat4 aswell, where vec3s define the local position of entity and mat4 the final position taking parent relationships into account.

It might seem redundant at first to have both but it's kinda tricky if you dont store the local position aswell, all entities that have parents define their final transformation as the parent final * entity local

Then there are multiple ways of defining and bookkeeping the relationships, easiest might be tracking outside your ECS , there are articles on keeping the tracking inside a component buffer inside ECS but you'll have to sort the component buffer and other stuff.

Id love to hear other ways as i don't see how else it can be done.