From 6d2292f3c732b9dda12c6425fff37126818273cf Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 29 Dec 2008 20:44:36 +0000 Subject: [PATCH] possibly fixed aiming issues when throwing plunger backwards git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2807 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/items/plunger.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index 18dfb1469..3138df535 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -54,11 +54,16 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER) // aim at this kart if it's not too far if(closest_kart != NULL && kartDistSquared < 30*30) { - const float time = sqrt(kartDistSquared) / (m_speed - closest_kart->getSpeed()); - - // calculate the approximate location of the aimed kart in 'time' seconds btVector3 closestKartLoc = closest_kart->getTrans().getOrigin(); - closestKartLoc += time*closest_kart->getVelocity(); + + if(!m_reverse_mode) + { + // FIXME - this approximation will be wrong if both karts' directions are not colinear + const float time = sqrt(kartDistSquared) / (m_speed - closest_kart->getSpeed()); + + // calculate the approximate location of the aimed kart in 'time' seconds + closestKartLoc += time*closest_kart->getVelocity(); + } // calculate the angle at which the projectile should be thrown // to hit the aimed kart