dimforge / dimforge/bevy_rapier

RevoluteJoint ignores Transform

Open
#457 4 comments 2 reactions 0 assignees View on GitHub
A-Dynamics A-Integration question S-not-started
Dominant language
Rust
Stars
1.6k
Forks
282
PR merge metrics
No merged PRs in 30d

Description

Rapier cylinders are spawned with the flat side facing up. I need to rotate them about the x axis to make them stand up in order to function as a wheel. I am able to do this without the Rapier by providing a `Transform` to the `PbrBundle`. However when I try to attach the cylinder to a `RevoluteJoint`, this rotation is lost. I saw an [example](https://github.com/gavlig/gryazevichki/blob/gryazevichki_rapier_v0.12.0-alpha.0/src/main.rs#L368) where you could provide a `position` to a `ColliderBundle`, but that appears to be a deprecated API. How I am I supposed to rotate the `Collider`?

```rust
let mut spawn_wheel = move |x, z| {
let wheel_y = constants::WHEEL_THICKNESS;

let joint = RevoluteJointBuilder::new(Vec3::Z)
.local_anchor1(Vec3::new(x, -constants::TRUCK_HEIGHT / 3., 2. * z))
.local_anchor2(Vec3::new(0., wheel_y, 0.));

let transform = Transform {
translation: Vec3::new(x, -constants::TRUCK_HEIGHT / 3., 2. * z),
rotation: -Quat::from_rotation_x(PI / 2.),
..default()
};

child_builder.spawn((
PbrBundle {
mesh: mesh.clone(),
material: material.clone(),
transform,
..default()
},
RigidBody::Dynamic,
Collider::cylinder(
constants::WHEEL_THICKNESS / 2.,
constants::WHEEL_DIAMETER / 2.,
),
ImpulseJoint::new(child_builder.parent_entity(), joint),
));
};
```
## Expected (joint/physics disabled):
![Screen Shot 2023-12-07 at 1 30 12 PM](https://github.com/dimforge/bevy_rapier/assets/4002738/f77ca5ed-afd0-473a-a8bd-9ee0d79e1e65)

## Actual (joints enabled):
![Screen Shot 2023-12-07 at 1 31 31 PM](https://github.com/dimforge/bevy_rapier/assets/4002738/941c37e4-181f-46fb-b74a-bbaaf1c9a2ea)

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.