-
-
Notifications
You must be signed in to change notification settings - Fork 259
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
I tried ported the vehicle_joints3 example from rapier to use bevy_rapier, but the steering move the body instead of the axle. #582
Comments
I've been working on a similar setup, it's nice to see some of the same struggles and I wish I saw this example sooner. I spent a good amount of time getting the mass properties and motor parameters to play nice and if positions/axes of colliders and joints didn't correspond perfectly things got weird. Also I definitely had issues when my axle colliders were to small, not sure why that effected the joints (seems like it unlocked locked axes). in case it helps here's my attempt
|
@Mitchelldscott your code works well, the axle is at the side of wheel which I think fixed the steering part. However, the driving is a bit wonky and the car wobbling side to side.
for (mut joint, mut impulse, tf, axle) in axle_query.iter_mut() {
match axle {
Axle::Steered => {
joint
.data
.as_mut()
.set_motor_position(JointAxis::AngY, steer, 10000.0, 1000.0);
}
_ => {}
}
// jump is just an impulse on each of the axle colliders.
// it should be an impulse that expands the suspension to it's limit
// then the car jumps because of the momentum of the chassis.
impulse.impulse = tf.rotation * Vec3::Y * jump;
impulse.torque_impulse = tf.rotation * Vec3::X * -jump / 60.0;
} Your also missing the differential speed code which improves the smoothness of the driving. let differential_strength = 0.5;
let sideways_shift = steer.sin() * differential_strength;
let speed_diff = if sideways_shift > 0.0 {
f32::hypot(1.0, sideways_shift)
} else {
1.0 / f32::hypot(1.0, sideways_shift)
};
let ms = [1.0 / speed_diff, speed_diff];
for (mut impulse_joint, wheel) in wheel_query.iter_mut() {
let ms = if wheel.is_left{
ms[0]
}else{
ms[1]
};
if wheel.is_driving{
impulse_joint
.data
.as_mut()
.set_motor_velocity(JointAxis::AngX, speed * ms, 50.0);
}
} Thanks to your code, I can continue my progress on the vehicle physics. |
Correction:Lowering the friction coefficient of the wheel to |
I had issues lowering the steering stiffness (the momentum of the car would cause the wheels to turn when accelerating). I didn't want to lower the friction because then the wheels may slip without you knowing, Correction:
|
rapier_issue4.mp4
The other issue is that the collider seems to be off, as the rear wheel of tire just floats instead of touching the surface of the orange obstacle.
Code is here
The text was updated successfully, but these errors were encountered: