#Bundle field as a child?..

3 messages · Page 1 of 1 (latest)

valid thunder
#

Lets say I just created a PlayerBundle, that contains several components: health, collider, movement bounds, etc.
One of the fields is a TransformBundle, since I need to specify the player location.
Another field is to be a SpriteBundle: it contains image handle and a Sprite component, that specifies rendering properties.
However, since (as far as I understand) all nested bundle components are "flattened" into the root one, I cannot just add both bundles together, because Transform and GlobalTransform can only be a singleton for an entity. I also don't want to use SpriteBundle' transform to be the player transform, because it will tie the player entity and its visual representation together.
The obvious solution is to add SpriteBindle as a child, but this kinda contradicts with the bundle idea of spawning all needed parts of an entity together. I, of course, can implement some function to do that.

However, is there any way of adding a component as a child within a bundle definition?

#

Bundle field as a child?..

kind ledge
#

I don't think so, but you can implement a method on a bundle like spawn(commands &mut Commands) in your bundle and handle your custom setup. That would mean it's not really a bundle anymore but you could treat it like a container of a few bundles with custom instructions on how to apply them hierarchy wise.