Open dankirkham opened 7 months ago
I noticed that there was a rapier3d::geometry::ColliderBuilder
and thought that I could use this to set the position of the Collider
. Unfortunately, this is not the same as a bevy_rapier3d::geometry::Collider
.
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),
));
error[E0277]: the trait bound `(MaterialMeshBundle<bevy::prelude::StandardMaterial>, bevy_rapier3d::dynamics::RigidBody, bevy_rapier3d::rapier3d::geometry::Collider, bevy_rapier3d::dynamics::ImpulseJoint): Bundle` is not satisfied
It should work if you convert joint
into a GenericJoint
and adjust the second local basis.
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));
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):