Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In component-based entity system, should game objects be reference counted? What about components? Tell me please your pro and contra.

share|improve this question
    
There should at least be a manager which creates and removes entities and its components. In the framework I've been working on Entity objects are never destroyed. However they are pooled for reuse. Their components on the other hand are destroyed. Also in my case an Entity is pretty much an "id" that holds everything together. The id is also the index at which the entity resides in my manager. –  Sidar Aug 17 '12 at 13:20
    
This is asking for a discussion. See the FAQ about what types of questions to ask here. –  Byte56 Aug 17 '12 at 14:07
    
Well if component will hold data specific for a gameobject you want have more then one reference to it. But you could use pooling. –  Kikaimaru Aug 17 '12 at 15:05
    
"Premature optimization is the root of all evil." If you manage your entities through a factory/manager, adding this later should be trivial. Write your game, not middleware! –  David Lively Aug 17 '12 at 15:50
add comment

closed as too broad by Josh Petrie Jul 22 '13 at 14:59

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 0 down vote accepted

I have a lot of minuses on this question, but I tried to use reference counting on my entities and components, and now I like this approach very very much. So if someone is interested, I stopped on using reference counting on these objects. I used this approach a bit and see now a lot of benefits and hope in future there won't be problems.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.