-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
sync_simple_transforms only checks for removed parents and doesn't filter for Without<Parent> #9517
Copy link
Copy link
Closed
Labels
A-TransformTranslations, rotations and scalesTranslations, rotations and scalesC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior
Description
Bevy version
Bevy main 3aad5c6
What you did
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, remove_and_set_parent)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
commands.spawn(SpriteBundle {
sprite: Sprite {
color: Color::WHITE,
custom_size: Some(Vec2::splat(100.)),
..Default::default()
},
transform: Transform::from_translation(50. * Vec3::ONE),
..Default::default()
})
.with_children(|commands| {
commands.spawn(SpriteBundle {
sprite: Sprite {
color: Color::RED,
custom_size: Some(Vec2::splat(110.)),
..Default::default()
},
transform: Transform::from_translation(50. * Vec3::ONE),
..Default::default()
});
});
}
fn remove_and_set_parent(
input: Res<Input<KeyCode>>,
mut commands: Commands,
query: Query<(Entity, &Parent), With<Sprite>>,
) {
if input.just_pressed(KeyCode::Space) {
for (e, p) in query.iter() {
commands.entity(e).remove_parent();
commands.entity(e).set_parent(p.get());
}
}
}
run it and you get:
after pressing space:
What went wrong
sync_simple_transforms only checks for removed parents and doesn't filter for Without<Parent>, so it overwrites the GlobalTransform of non-orphan entities that removed and then added a parent since the last update.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-TransformTranslations, rotations and scalesTranslations, rotations and scalesC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behavior