#Query fails

1 messages · Page 1 of 1 (latest)

visual hatch
#

I created component bundle in src/main.rs :

#[derive( Debug, Default, Component)]
pub struct ChunkBundle {
     ....
    pub visibility: Visibility,
    pub chunk: Chunk,
}

#[derive(Debug, Clone, Component, Default, TypePath)]
pub struct Chunk {....}

So when i run fn inside example/test.rs it works, but inside src/main.rs it fails.

example/test.rs

commands.spawn(ChunkBundle { ..default()}
...
fn FN(query: Query<&mut Chunk>,){
  for (mut t) in &mut query {
      WORKS FINE
  }
}
src/main.rs
fn FN_MAIN(query: Query<&mut Chunk>,){
  WORKS
  for (mut t) in &mut query {
      FAILS!!!!!!!
      as if query in empty!!!!!
  }
}
undone olive
visual hatch
visual hatch
undone olive
visual hatch
#

I installed it , and my scene is rendered as expected

visual hatch
#

i run in terminal cargo run --example test.rs

undone olive
#

I mean your app.add_systems(....)

visual hatch
#

in main.rs: ```pub struct ChunkPlugin;

impl Plugin for ChunkPlugin {
fn build(&self, app: &mut App) {
....

    let render_app = match app.get_sub_app_mut(RenderApp) {
        Ok(render_app) => render_app,
        Err(_) => return,
    };

    render_app
        ...
        // fn with query
        .add_systems(Render, queue_custom_pipeline.in_set(RenderSet::Queue))

        ....
}

fn finish(&self, app: &mut App) {
    let render_app = match app.get_sub_app_mut(RenderApp) {
        Ok(render_app) => render_app,
        Err(_) => return,
    };

    render_app.init_resource::<CustomPipeline>();
}

}

#

in test.rs App::new() .... .add_plugins(ChunkPlugin) ...

visual hatch
undone olive
#

Hmm ok hopefully someone else can help here, I haven't touched rendering stuff yet

prime niche
#

Just to check… do you spawn it in main too?

undone olive
visual hatch