Jump to content
  • Advertisement
Sign in to follow this  
lexs

Unity Component system and entites (Yet another)

This topic is 3803 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

My component system is based upon Sneftels post (http://www.gamedev.net/community/forums/topic.asp?topic_id=463508) on the subject with components merely acting as data components while systems doing all the work. My system base class has a virtual setup function where it can ask for a update every x ms or every frame using delegates. This means a system can have several updates at various frequencies. During each update the system can request a list of all entities added the the model/scene and query components added to the entity or it can use an internally stored list of components created by the subsystem itself if it doesn't need access other components. Because each system can have an arbitrary number of update methods I don't know how to implement that another system may want to update pre or post that system, eg the HoverSystem needs to run before the main update of the PhysicsSystem to apply the necessary forces etc. Should I just revert to each system having exactly one update() method but it can still specify how often it should be called?

Share this post


Link to post
Share on other sites
Advertisement
I had similar issues with trying to get order of updates correct. I had stuff like onPreAdvanceTime( u32 tick ), onAdvanceTime( u32 tick ) and onPostAdvanceTime( u32 tick ). It worked for simple stuff only.

Since I was updating my objects using my portal system, I could also get double updates if an object changed room.

I ended up making master lists of each component type that needed updates. In yout case I guess you call them systems. I used to like the idea of updating all my objects with an onUpdate()ish interface but really this just makes things harder to debug and adds virtual functions. Neither are killers but then you hvae to ask yourself what does it get you? Really you should know the order of each system and I would even say that you are more likely to be able to optimize by iterating over systems then a scatter gather of generic objects.

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!