Parent scale ignored if child doesn't have transform bundle
In normal bevy afaict a child entity is affected by parent transforms regardless of whether it has a transform bundle itself or not. If it isn't present, it's as if the child had the default transforms.
Bevy Rapier seems to only respect the parent scale if the child has a transform bundle too.
Here's a small example:
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
fn main() {
App::new()
.insert_resource(ClearColor(Color::srgb(0xF9 as f32 / 255.0, 0xF9 as f32 / 255.0, 0xFF as f32 / 255.0)))
.add_plugins(
(DefaultPlugins, RapierPhysicsPlugin::<NoUserData>::default(), RapierDebugRenderPlugin::default()),
)
.add_systems(Startup, (setup_graphics, setup_physics))
.run();
}
pub fn setup_graphics(mut commands: Commands) {
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-30.0, 30.0, 100.0).looking_at(Vec3::new(0.0, 10.0, 0.0), Vec3::Y),
..Default::default()
});
}
pub fn setup_physics(mut commands: Commands) {
// Ground
let ground_size = 200.1;
let ground_height = 0.1;
commands.spawn(
(
TransformBundle::from(Transform::from_xyz(0.0, -ground_height, 0.0)),
Collider::cuboid(ground_size, ground_height, ground_size),
),
);
commands.spawn_empty().insert(RigidBody::Dynamic).insert(TransformBundle::from_transform(Transform {
translation: Vec3::new(0., 10., 0.),
scale: Vec3::new(0.5, 0.5, 0.5),
..Default::default()
})).with_children(|commands| {
commands.spawn_empty().insert(Collider::cuboid(1., 1., 1.));
});
commands.spawn_empty().insert(RigidBody::Dynamic).insert(TransformBundle::from_transform(Transform {
translation: Vec3::new(5., 10., 0.),
scale: Vec3::new(0.5, 0.5, 0.5),
..Default::default()
})).with_children(|commands| {
commands.spawn_empty().insert(TransformBundle::default()).insert(Collider::cuboid(1., 1., 1.));
});
}
https://github.com/dimforge/bevy_rapier/discussions/441 Just found this, here's another user getting tripped up.
This also looks related: https://github.com/dimforge/bevy_rapier/issues/172
To clarify, I think if the parent transform were ignored entirely this wouldn't be as much of an issue, it's the fact that the parent transform is only applied sometimes, due to seemingly unrelated changes to another entity, that this is an issue.