How do I add a parent entity to a scene in Bevy?

Viewed 603

I'm trying to attach a ComponentFoo to a whole scene coming from a gltf file. From what I understand I need to put the scene entities under a parent entity possessing that ComponentFoo.

commands
    .spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf"));
    .with(ComponentFoo {})

gives the following error:

panicked at 'Cannot add component because the 'current entity' is not set.

and as expected, that doesn't work either:

commands
    .spawn_scene(asset_server.load("models/FlightHelmet/FlightHelmet.gltf"));
    .current_entity()
    .unwrap()

How do I get a parent Entity of the scene? Or at list iterate over all entities of that scene? The gltf loader seems to add a parent entity containing a Transform at the root of the loaded scenes, how could I pinpoint it?

0 Answers
Related