Download

Building Systems: Actors vs Components

I am considering adding a building system to a small game I am noodling on (player can place walls, floors, etc in the world). My main objective is to educate myself. The first iteration will likely be very simple adding and removal of collidable meshes on a grid, however my immediate next step will be to play with concepts like structural integrity and pipe networks where many placed meshes will need to communicate with each other.

For this and other reasons, I am torn between having each placed object be an actor, or a component. If it’s a component within a master actor, then I could take advantage of mesh instancing, and the pipe/structural logic could live in the actor. My fear with having every instance as its own actor is that it would not scale very well, and players who would want to build lots of things would suffer framerate issues.

However I’m pretty new in this journey, and I can’t say I am very knowledgeable about performance optimization. I am wondering if anyone here has advice on which route to choose.

Instances will be a better solution.
If you are making a system with free placing constructions, then you cannot do without actors, because you will need collision boxes. You will need to place in place of each inctance of its empty collision actor. In this case, you will need to control their ticks and the load of logic in them, or just disable all ticks. If positioning is on a grid, then all objects can be represented as a set of data assigned to each cell or set of cells. Both options have their pros and cons, it all depends on your organization of the game.
But, I think that in both cases it is better to have a common object manager that will control all the logic of the constructions, so you will have some centralization and you will not get confused about what is happening where and when.

Actors are the way to go, honestly I have been making Conan Exiles like System since past few months in my spare time, I have tried many techniques including getting vertices,Normals from Mesh for snapping, using instance Meshes, and ofc Scene Components. and at the end Actors were the best option not only easy to work with but also tried and test technique in other games.

Now what i have in mind is instead of using Actor with Mesh components I can use an instanced mesh of Type and adjust its child’s location to my Placed Actor’s Location this can reduce draw calls.

Still with OOP there is just no smooth way to achieve huge Quantities of building blocks due to cache misses even if we fix the draw call problem using instanced meshes we would still have tons of actors or Components to keep track of or update if needed.

I would suggest if you are an experienced programmer look into ECS. sadly I don’t have much experience in programing other than OOP I am stuck for now but for a small game my solution works fine but I want players to build limitless.