Skip to content

Adding Entity as child to other entity makes it invisible #5081

@ashirviskas

Description

@ashirviskas

Bevy version

0.7.0

[Optional] Relevant system information

OS: Arch Linux
Cargo version: cargo 1.63.0-nightly

2022-06-23T15:29:27.512314Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD RADV RENOIR", vendor: 4098, device: 5708, device_type: IntegratedGpu, backend: Vulkan }

What you did

I tried adding new entities as children to parent entity.

What went wrong

Child entities are invisible, but they still function (as colliders for example).

Additional information

Code that works and renders all entities (only included shortened version for the left wall, but code does the same for all of the walls):

let cell_wall_entity_left = commands
    .spawn()
    .insert_bundle(
        SpriteBundle {
            sprite: Sprite {
                color: Color::rgb(0.5, 0.5, 0.3),
                ..default()
            },
            transform: Transform {
                translation: wall_position.extend(0.1),
                scale: Vec3::new(40., 5. , 1.),
                ..default()
            },
            ..default()
        },
    )
    .insert(Collider)
    .id();
let parent_cell = commands
    .spawn_bundle(CellBundle::new(
        SpriteBundle {
            sprite: Sprite {
                color: cell_type.to_color(),
                ..default()
            },
            transform: Transform {
                translation: cell_position.extend(0.),
                scale: Vec3::new(CELL_SIZE.x, CELL_SIZE.y, 1.0),
                ..default()
            },
            ..default()
        },
        Cell::new(),
        Collider,
    ));

image

If I change the last line to:

    )).insert(CellType::Cell).push_children(&[cell_wall_entity_left]);

Then it looks like this:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenA-TransformTranslations, rotations and scalesC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions