#Intended way to manage relationships

8 messages · Page 1 of 1 (latest)

cosmic scaffold
#

What is the intended way to manage relationships (especially with sub sub children) like when loading a gltf?
Assume we have something like a Player entity with a gltf loaded into a SceneRoot as a child.
That SceneRoot then has its own children like meshes and animations and whatever.

Now how am I supposed to play an animation of a specific player? I can query all animations but I can not tell which Player that belongs to, in order to do that I would somehow have to get the grandparent of that animation entity.
Same thing applies to finding out which player a mesh belongs to given the mesh entity (like with MeshRayCast).

radiant forum
#

you want a quick way to query for the AnimationPlayer of a Player without going through the hierarchy, right?

#

you can listen for the SceneInstanceReady of the Player and then create a relationship between the entity with Player (and SceneRoot) and the entity with AnimationPlayer

#

the you will be able query Query<(&Player, &LinkToAnimationPlayer)> and use LinkToAnimationPlayer::get to then get the entity from Query<&mut AnimationPlayer>

cosmic scaffold
radiant forum
#

yes, but that only happens one, instead of every time you would want to change the animations

cosmic scaffold
radiant forum
#

children: Query<&Children> for child in children.iter_descendants(parent) {}