2

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?

Simon
  • 860
  • 7
  • 23
  • This might be relevant https://github.com/bevyengine/bevy/blob/master/examples/asset/asset_loading.rs#L24. You might want to wait to use the loaded asset. – Will Nov 09 '20 at 12:10
  • Thanks. For the record, this might be relevant as well: https://github.com/bevyengine/bevy/discussions/654#discussioncomment-95071 And seems to indicate that there's no easy solution for now. – Simon Nov 09 '20 at 12:31

0 Answers0