Many game engines I've seen which are based on an Entity Component System. It has some kind of a Transform Component as a necessary component attached to all of their entities. While this does seem to make kind of sense considering an entity is only some kind of property bag and a collection of components and transformations are world space behavior (hence just part of the composition). I've noticed two other things which are very weird:
Transform components are used to build up the hierarchy between entities as they have a parent entity as well as child entities
Transform components are specialized for only a single kind of world space, e.g. 2D or 3D.
Examples:
The Unity3D engine. Entity children and parents seem to be accessed through the Transform Component of each entity. Also, the Transform Component features coordinates in 3D vectors.
The Xenko Game Engine (previously Paradox3D), which can bee seen on GitHub.
So, is this a common practice? Best/worst practice? What's the reason behind having:
- a fixed Transform component,
- making the Transform component only suitable for one world space
- using the Transform component as an hierarchy graph?
Transform
component of some variety and it makes sense that it would be the transform which has children/parents, as that hierarchical relationship is spatially based (every transforms' global position is effected by the transforms of all of its parents). \$\endgroup\$ – Draco18s no longer trusts SE Jan 20 '16 at 21:42