Jump to content
  • Advertisement
Sign in to follow this  

Entity Component System - Accessing Components

This topic is 1424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm experimenting with building an Entity Component System, and I've run into the problem of accessing components. I am currently just using a method for each individual component type and a specific typed variable. I'd like to change to something better, but I don't know what is best.

I've thought of simply searching through a dynamic list each time a component is accessed, but I'm afraid this will start to lag if there are many access calls per second (which there currently are). Also, I'm afraid a dynamic list will take longer to append and will be less memory efficient than what I have now.

I googled the question and someone suggested a hash map, which has a constant access time, but I have never used a hash map (I know :O) and after a little bit of research, I still couldn't see the benefit of using one for something like this.

So my question is, in an entity component system, what is a good way to quickly and efficiently access components?

Share this post

Link to post
Share on other sites

Since you do not describe how you are defining and using your components (other then that they are accessed through a method), it is hard to give any direct advice as how to store and access them.


There are many forms of entity-compoennt systems - some where an entity an object with a list of components and others where an entity is just a an id and the components are stored in seperat lists and accessed through that entity id.


I am personally using an approach based on the latter (where an entyity is represented by an id) since I like the simplicity and performance of that method,

I also think its very readable, but it can be a bit hard to wrap your head around initially if you are more used to the object oriented style of programming.


I started out by following some great articles here on gamedev:






Have a look and see if that is something you could use maybe.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!