more computed center of mass

This commit is contained in:
Joe Ardent 2025-04-28 21:34:18 -07:00
parent 81bec0b2b4
commit 5596d883c5

View file

@ -115,14 +115,19 @@ mod systems {
} }
pub(super) fn apply_lean( pub(super) fn apply_lean(
mut bike_query: Query<(&Transform, &mut ExternalForce, &mut CatControllerState)>, mut bike_query: Query<(
&Transform,
&ComputedCenterOfMass,
&mut ExternalForce,
&mut CatControllerState,
)>,
wheels: Query<&WheelState>, wheels: Query<&WheelState>,
time: Res<Time>, time: Res<Time>,
settings: Res<CatControllerSettings>, settings: Res<CatControllerSettings>,
lean: Res<CyberLean>, lean: Res<CyberLean>,
mut gizmos: Gizmos, mut gizmos: Gizmos,
) -> Result { ) -> Result {
let (xform, mut force, mut control_vars) = bike_query.single_mut()?; let (xform, com, mut force, mut control_vars) = bike_query.single_mut()?;
let mut factor = 1.0; let mut factor = 1.0;
for wheel in wheels.iter() { for wheel in wheels.iter() {
@ -164,7 +169,7 @@ mod systems {
force.apply_force_at_point( force.apply_force_at_point(
lean_force, lean_force,
xform.translation + *xform.up(), xform.translation + *xform.up(),
xform.translation, xform.translation + com.0,
); );
gizmos.arrow( gizmos.arrow(
xform.translation + *xform.up(), xform.translation + *xform.up(),