dimforge / dimforge/bevy_rapier

Parent scale ignored if child doesn't have transform bundle

Open
#555 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

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::::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.));
});
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.