Entity/Component based engine rendering separation from logic
- by Denis Narushevich
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?