bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.4k stars 3.59k forks source link

ChildBuilder does not respect required components #16380

Closed Hexorg closed 1 week ago

Hexorg commented 1 week ago

Bevy version

"0.15.0-rc.3"

What you did

I ran this setup function for Startup schedule:

fn setup(mut commands:Commands) {
    let mut e = commands.spawn_empty();
    e.insert(Transform::default());
    e.with_children(|b| {
        b.spawn((PointLight::default(), Transform::IDENTITY));
    });
}

What went wrong

Expected result: No warning messages.

Result I get:

2024-11-13T22:31:15.585476Z  WARN bevy_hierarchy::valid_parent_check_plugin: warning[B0004]: Entity 7v1 with the InheritedVisibility component has a parent without InheritedVisibility.
This will cause inconsistent behaviors! See: https://bevyengine.org/learn/errors/b0

I checked and Entity 7v1 is the child

alice-i-cecile commented 1 week ago

Here's a link to the relevant source: https://github.com/bevyengine/bevy/blob/aab36f39513bc30e148d106f6d2f11f4e85264b5/crates/bevy_hierarchy/src/child_builder.rs#L430

I bet this is https://github.com/bevyengine/bevy/issues/16034 again. Can you test this on #16219?

Hexorg commented 1 week ago

Just downloaded and built nakedible/bevy world-entity-mut-flushes branch but still get the same warning.

cart commented 1 week ago

This isn't broken behavior. The parent doesn't have InheritedVisibility. Transform does not require Visibility. You need to insert Visibility on the parent, which will pull in InheritedVisibility.