From 4eedeb0bc1f40f6a67f609514f9732c8ec5a5c6d Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Oct 2013 14:51:44 +0000 Subject: Improved autopilot roll control in formation flight. --- src/game/base/ship.cc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/game/base') diff --git a/src/game/base/ship.cc b/src/game/base/ship.cc index c017ce1..5d8ace2 100644 --- a/src/game/base/ship.cc +++ b/src/game/base/ship.cc @@ -1217,13 +1217,18 @@ void Ship::frame_autopilot_formation(const unsigned long elapsed, core::Entity * } else { target_direction = 0.0f; target_pitch = 0.0f; + } - if (reference.up().z() < 0) { - // upward-down - target_roll = math::sgnf(reference.up().y()); - } else { - target_roll = reference.up().y(); - } + + if (reference.up().z() < 0.0f) { + // upward-down + target_roll = math::sgnf(reference.up().y()); + + } else if (reference.up().z() + MIN_DELTA < 1.0f) { + target_roll = reference.up().y(); + + } else { + target_roll = 0.0f; } if (target->type() == core::Entity::Controlable) { -- cgit v1.2.3