Entity/Component based engine rendering separation from logic
Posted
by
Denis Narushevich
on Game Development
See other posts from Game Development
or by Denis Narushevich
Published on 2013-03-06T12:31:46Z
Indexed on
2013/06/25
4:30 UTC
Read the original article
Hit count: 504
I noticed in Unity3D that each gameObject(entity) have its own renderer component, as far I understand, such component handle rendering logic.
I wonder if it is a common practice in entity/component based engines, when single entity have renderer components and logic components such as position, behavior altogether in one box?
Such approach sound odd to me, in my understanding entity itself belongs to logic part and shouldn't contain any render specific things inside.
With such approach it is impossible to swap renderers, it would require to rewrite all that customized renderers.
The way I would do it is, that entity would contain only logic specific components, like AI,transform,scripts plus reference to mesh, or sprite. Then some entity with Camera component would store all references to object that is visible to the camera. And in order to render all that stuff I would have to pass Camera reference to Renderer class and render all sprites,meshes of visible entities.
Is such approach somehow wrong?
© Game Development or respective owner