diff --git a/src/flyable.cpp b/src/flyable.cpp index 53d0e37ab..55d093edd 100644 --- a/src/flyable.cpp +++ b/src/flyable.cpp @@ -141,7 +141,7 @@ Flyable::~Flyable() //----------------------------------------------------------------------------- void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared, - btVector3 *minDelta, const Kart* inFrontOf) const + btVector3 *minDelta, const Kart* inFrontOf, const bool backwards) const { btTransform tProjectile = (inFrontOf != NULL ? inFrontOf->getTrans() : getTrans()); @@ -170,7 +170,7 @@ void Flyable::getClosestKart(const Kart **minKart, float *minDistSquared, trans.getBasis()[1][1], trans.getBasis()[2][1]); - float angle = to_target.angle(direction); + const float angle = to_target.angle( backwards ? -direction : direction ); if(fabsf(angle) > 1) continue; } diff --git a/src/flyable.hpp b/src/flyable.hpp index 2d1c4c3eb..a935b3959 100644 --- a/src/flyable.hpp +++ b/src/flyable.hpp @@ -82,7 +82,8 @@ protected: Useful e.g. for throwing projectiles in front only. */ void getClosestKart(const Kart **minKart, float *minDistSquared, - btVector3 *minDelta, const Kart* inFrontOf=NULL) const; + btVector3 *minDelta, const Kart* inFrontOf=NULL, + const bool backwards=false) const; /** init bullet for moving objects like projectiles */ void createPhysics(float y_offset, const btVector3 velocity, diff --git a/src/items/plunger.cpp b/src/items/plunger.cpp index f5075758a..76ef61c98 100644 --- a/src/items/plunger.cpp +++ b/src/items/plunger.cpp @@ -39,7 +39,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER) // find closest kart in front of the current one const Kart *closest_kart=0; btVector3 direction; float kartDistSquared; - getClosestKart(&closest_kart, &kartDistSquared, &direction, kart /* search in front of this kart */); + getClosestKart(&closest_kart, &kartDistSquared, &direction, kart /* search in front of this kart */, m_reverse_mode); btTransform trans = kart->getTrans(); @@ -52,7 +52,7 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER) float pitch = kart->getTerrainPitch(heading); // aim at this kart if it's not too far - if(closest_kart != NULL && kartDistSquared < 30*30 && !m_reverse_mode) // aiming doesn't work backwards + if(closest_kart != NULL && kartDistSquared < 30*30) { const float time = sqrt(kartDistSquared) / (m_speed - closest_kart->getSpeed()); @@ -69,15 +69,18 @@ Plunger::Plunger(Kart *kart) : Flyable(kart, POWERUP_PLUNGER) btMatrix3x3 m; m.setEulerZYX(pitch, 0.0f, projectileAngle); trans.setBasis(m); + + createPhysics(y_offset, btVector3(0.0f, m_speed*2, 0.0f), + new btCylinderShape(0.5f*m_extend), 0.0f /* gravity */, false /* rotates */, false, &trans ); } else { trans = kart->getKartHeading(); + + createPhysics(y_offset, btVector3(0.0f, m_speed*2, 0.0f), + new btCylinderShape(0.5f*m_extend), 0.0f /* gravity */, false /* rotates */, m_reverse_mode, &trans ); } - createPhysics(y_offset, btVector3(0.0f, m_speed*2, 0.0f), - new btCylinderShape(0.5f*m_extend), 0.0f /* gravity */, false /* rotates */, m_reverse_mode, &trans ); - if(m_reverse_mode) m_rubber_band = NULL; else