-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RevoluteJoint ignores Transform #457
Comments
I noticed that there was a let rotation = nalgebra::UnitQuaternion::from_axis_angle(
&nalgebra::Vector3::z_axis(),
std::f32::consts::FRAC_PI_2,
);
let position = nalgebra::Isometry3 {
rotation,
..Default::default()
};
let collider_builder = ColliderBuilder::new(SharedShape::cylinder(
constants::WHEEL_THICKNESS / 2.,
constants::WHEEL_DIAMETER / 2.,
));
// This yields a rapier3d::geometry::Collider which is
// NOT a bevy_rapier3d::geometry::Collider and thus
// does not implement Bundle.
let collider = collider_builder.position(position).build();
child_builder.spawn((
PbrBundle {
mesh: mesh.clone(),
material: material.clone(),
..default()
},
RigidBody::Dynamic,
collider,
ImpulseJoint::new(child_builder.parent_entity(), joint),
));
|
It should work if you convert let mut joint: GenericJoint = RevoluteJointBuilder::new(Vec3::Z)
.local_anchor1(Vec3::new(x, -constants::TRUCK_HEIGHT / 3., 2. * z))
.local_anchor2(Vec3::new(0., wheel_y, 0.))
.into();
joint.set_local_basis2(Quat::from_rotation_z(std::f32::consts::FRAC_PI_2)); |
Is this considered a bug? |
The above workaround seemed very promising at first, but I was seeing some very bizarre behavior from my vehicle -- almost as if the motor/collider were applying their forces in their "original" orientation or something. My bike was behaving sort of like a "vibrobot". Ultimately, I was able to work around this by burying the collider in the hierarchy, giving the collider and joint "separate transforms." commands
.spawn((
TransformBundle::default(),
RigidBody::Dynamic,
ImpulseJoint::new(bike, joint),
))
.with_children(|parent| {
parent.spawn((
TransformBundle::from_transform(Transform::from_rotation(rotation)),
Collider::cylinder(wheel_thickness, wheel_radius),
));
}); |
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 thePbrBundle
. However when I try to attach the cylinder to aRevoluteJoint
, this rotation is lost. I saw an example where you could provide aposition
to aColliderBundle
, but that appears to be a deprecated API. How I am I supposed to rotate theCollider
?Expected (joint/physics disabled):
Actual (joints enabled):
The text was updated successfully, but these errors were encountered: