~starkingdoms/starkingdoms

cb50998c3b15746f9231b97c7e24e7eead862618 — ghostly_zsh 22 days ago 6cccb90
fix: target_unit_vector is now rotated
1 files changed, 11 insertions(+), 10 deletions(-)

M crates/unified/src/client/ship/thrusters.rs
M crates/unified/src/client/ship/thrusters.rs => crates/unified/src/client/ship/thrusters.rs +11 -10
@@ 76,6 76,12 @@ fn solve_thrust(
    solution.thrusters_on.clear();
    solution.converged = false;

    let Ok((our_parts, hearty_transform, hearty)) = me.single() else {
        error!("could not solve for thrust: hearty does not exist?");
        error!("failed to solve for thrust after {}ms", start.elapsed().as_millis());
        return;
    };

    // determine our target vector:
    // unit vector in the intended direction of movement



@@ 86,16 92,16 @@ fn solve_thrust(
    let mut target_unit_vector = Vec3::ZERO;

    if input.pressed(&ClientAction::ThrustForward) {
        target_unit_vector += Vec3::new(0.0, -1.0, 0.0);
        target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, -1.0, 0.0);
    }
    if input.pressed(&ClientAction::ThrustBackward) {
        target_unit_vector += Vec3::new(0.0, 1.0, 0.0);
        target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, 1.0, 0.0);
    }
    if input.pressed(&ClientAction::ThrustRight) {
        target_unit_vector += Vec3::new(-1.0, 0.0, 0.0);
        target_unit_vector += hearty_transform.rotation() * Vec3::new(-1.0, 0.0, 0.0);
    }
    if input.pressed(&ClientAction::ThrustLeft) {
        target_unit_vector += Vec3::new(1.0, 0.0, 0.0);
        target_unit_vector += hearty_transform.rotation() * Vec3::new(1.0, 0.0, 0.0);
    }
    if input.pressed(&ClientAction::TorqueCw) {
        target_unit_vector += Vec3::new(0.0, 0.0, -1.0);


@@ 112,11 118,6 @@ fn solve_thrust(
        return;
    }

    let Ok((our_parts, hearty_transform, hearty)) = me.single() else {
        error!("could not solve for thrust: hearty does not exist?");
        error!("failed to solve for thrust after {}ms", start.elapsed().as_millis());
        return;
    };
    let mut all_parts = vec![hearty];
    if let Some(parts) = our_parts {
        all_parts.extend(parts.iter());


@@ 215,4 216,4 @@ fn solve_thrust(
    *solution = new_soln;
    events.write(ThrustEvent(solution.clone()));
    return;
}
\ No newline at end of file
}