diff --git a/src/items/cake.cpp b/src/items/cake.cpp index c59419caf..187ef3b29 100644 --- a/src/items/cake.cpp +++ b/src/items/cake.cpp @@ -62,11 +62,12 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE) float pitch = kart->getTerrainPitch(heading); // Find closest kart in front of the current one + const bool backwards = kart->getControls().m_look_back; const Kart *closest_kart=NULL; Vec3 direction; float kartDistSquared; getClosestKart(&closest_kart, &kartDistSquared, &direction, - kart /* search in front of this kart */); + kart /* search in front of this kart */, backwards); // aim at this kart if 1) it's not too far, 2) if the aimed kart's speed // allows the projectile to catch up with it @@ -86,6 +87,12 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE) // apply transformation to the bullet object (without pitch) trans.setRotation(btQuaternion(btVector3(0,1,0), fire_angle)); + + m_initial_velocity = Vec3(0.0f, up_velocity, m_speed); + + createPhysics(forward_offset, m_initial_velocity, + new btCylinderShape(0.5f*m_extend), -m_gravity, + true /* rotation */, false /* backwards */, &trans); } else { @@ -93,13 +100,14 @@ Cake::Cake (Kart *kart) : Flyable(kart, POWERUP_CAKE) // kart is too far to be hit. so throw the projectile in a generic way, // straight ahead, without trying to hit anything in particular trans = kart->getKartHeading(pitch); + + m_initial_velocity = Vec3(0.0f, up_velocity, m_speed); + + createPhysics(forward_offset, m_initial_velocity, + new btCylinderShape(0.5f*m_extend), -m_gravity, + true /* rotation */, backwards, &trans); } - m_initial_velocity = Vec3(0.0f, up_velocity, m_speed); - - createPhysics(forward_offset, m_initial_velocity, - new btCylinderShape(0.5f*m_extend), -m_gravity, - true /* rotation */, false /* backwards */, &trans); //do not adjust height according to terrain setAdjustUpVelocity(false);