#Sprite Invisible when child of an entity

5 messages · Page 1 of 1 (latest)

hollow lotus
#

When I do this, the sprites are invisible. If I remove the push children they are visible

fn spawn_map(mut commands: Commands, tilemap: Res<TileMap>) {
    let mut tiles = Vec::new();
    for x in 0..10 {
        for y in 0..10 {
            let tile = Tiles::WallUp;
            tiles.push(
                commands
                    .spawn((
                        Tile,
                        Name::new(format!("Tile({x}, {y})")),
                        tilemap.create_sprite(SpawnSpriteOption {
                            index: tile.sprite(),
                            size: Vec2::splat(32.0),
                            position: Vec3::new(x as f32 * 32.0, y as f32 * 32.0, 0.0),
                        }),
                    ))
                    .id(),
            );
        }
    }
    commands
        .spawn((
            Map,
            Name::new("Map"),
            Transform::default(),
            GlobalTransform::default(),
            ComputedVisibility::default(),
        ))
        .push_children(&tiles);
}
hexed lake
minor gull
#

Bevy entities have next to nothing by default. I'd suggeat making the parent a SpatialBundle

#

It includes a Transform, Visibility, ComputedVisibility, and GlobalTransform components. Consider it a minimal set of components for something that exists within the game world