Skip to content

How to access GridCommands via a Query? #36

@motgenror

Description

@motgenror

Amazing crate, thank you. I'm struggling to figure out: after I spawned a new grid and some children in it, how do you come back to that grid and add more entities to it? Grid is a component and it can be queried for:

fn setup1(
    mut commands: Commands,
) {
    commands.spawn_big_space_default(|root_grid| {
        root_grid.insert(RootGrid);
        // add stuff to root_grid ...
    }
}
// ...
fn setup2(
    mut root_grid: Query<&mut Grid<GP>, With<RootGrid>>,
) {
    let mut root_grid = root_grid.single_mut();

    // ERROR: `root_grid` is not a `GridCommands`, so `spawn_spatial()` is not found for it
    root_grid.spawn_spatial((...));
}

I guess my question applies to any grid, not just the root one. Please help?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions