Quote:Original post by dmatterQuote:Original post by TesshuQuote:Original post by dmatterQuote:Original post by Tesshu
In my system I handle these problems at construction time. All components are added to the object then coms can do discovery when onConstruct() is called on the object. For example, I might have a ComCamera1st that follows the head of the ComSkinMesh3d, if ComSkinMesh3d isn't found then it looks for a ComPhysics and if that isn't found it looks for a ComStaticFrame etc... I really can't see how else to do this sort of thing. Coms that do anything non-trivial pretty much have to talk to other coms.
Perhaps that behaviour belongs elsewhere, such as the scene-graph, rather than the component system. You would have a camera node and attach to it an entity.
I don't see that as much of a solution since you still need to follow the head position.
Well it depends on exactly what you need, but a simple solution might be:ROOT | \---Group Transform Node | \---Camera | \---SkinnedMesh
The camera is set up to hover about 4 meters above ground and to look-at the point where the mesh's head is known to be. If the transform node changes then the camera and the mesh both move together thus the camera follows the players head.
IMO, a camera isn't really a good candidate for the component system.
I guess this is a perfect example of how it's not always easy to determine what should be in the com system or not :)
I have a Sim_ComFollowBone that, well follows a bone on a skinned model. So I can use this com to put a weapon in a hand, make a halo appear over a head or make a camera follow a bone. Keep in mind that some of my coms, such as Sim_ComCamera, are really wrappers for more lower level systems. I really can't see why you wouldn't want it to be com. One of the features of the system is sharing code. Using this method I can create many different types of objects that can be used as a camera.