Reduce the height of a rubber ball in a cannon over time, so that

it starts closer to the ground when released after the cannon.
This commit is contained in:
hiker 2017-05-12 17:52:15 +10:00
parent 490bef516e
commit bdbc7fd728
2 changed files with 11 additions and 0 deletions

View File

@ -151,7 +151,10 @@ void RubberBall::initializeControlPoints(const Vec3 &xyz)
void RubberBall::setAnimation(AbstractKartAnimation *animation)
{
if (!animation)
{
initializeControlPoints(getXYZ());
m_height_timer = 0;
}
Flyable::setAnimation(animation);
} // setAnimation

View File

@ -293,7 +293,15 @@ void CannonAnimation::update(float dt)
btClamp(m_fraction_of_line, -1.0f, 1.0f);
} // if m_kart
else
{
// If a rubber ball is in this cannon, reduce its height over
// time so that it starts closer to the ground when released
float height = m_delta.getY();
float radius = m_flyable->getExtend().getY();
height = (height - radius) * 0.95f + radius;
m_delta.setY(height);
all_heading.setValue(0, 0, 0, 1);
}
// Determine direction orthogonal to the curve for the sideway movement
// of the kart.