When driving backwards karrs will now slowdown depending on terrain

(fixes bug 2554280).


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@3095 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk
2009-02-02 14:14:27 +00:00
parent 06c60aee6c
commit f48f8e8dd2
2 changed files with 19 additions and 9 deletions

View File

@@ -95,7 +95,7 @@
(skid-visual 0.16) ;; Additional graphical rotation of kart.
;; Bullet physics attributes
(brake-factor 2.75 )
(brake-factor 11.0 )
;; Defines the smallest turn radius at lowest speed (4.64 m at
;; speed 0) and at high speed (13.5 m at speed 12 m/s). Maximum
;; steering angles for speeds in between will be interpolated. This
@@ -122,7 +122,7 @@
(wheel-width 0.3 )
(chassis-linear-damping 0.2 )
(chassis-angular-damping 30.2 )
(max-speed-reverse-ratio 0.4 ) ;; percentage of max speed for reverse gear
(max-speed-reverse-ratio 0.3 ) ;; percentage of max speed for reverse gear
(suspension-rest 0.2 )
(suspension-travel-cm 19 )

View File

@@ -794,21 +794,31 @@ void Kart::updatePhysics (float dt)
m_vehicle->applyEngineForce(0.f, 3);
//apply the brakes
for(int i=0; i<4; i++) m_vehicle->setBrake(getBrakeFactor() * 4.0f, i);
for(int i=0; i<4; i++) m_vehicle->setBrake(getBrakeFactor(), i);
m_skidding*= 1.08f;//skid a little when the brakes are hit (just enough to make the skiding sound)
if(m_skidding>m_kart_properties->getMaxSkid())
m_skidding=m_kart_properties->getMaxSkid();
}
else
else // m_speed < 0
{
resetBrakes();
// going backward, apply reverse gear ratio (unless he goes too fast backwards)
if ( fabs(m_speed) < getMaxSpeedOnTerrain()*m_max_speed_reverse_ratio )
if ( -m_speed < getMaxSpeedOnTerrain()*m_max_speed_reverse_ratio )
{
// the backwards acceleration is artificially increased to allow
// players to get "unstuck" quicker if they hit e.g. a wall
m_vehicle->applyEngineForce(-engine_power*2.5f, 2);
m_vehicle->applyEngineForce(-engine_power*2.5f, 3);
// The backwards acceleration is artificially increased to
// allow players to get "unstuck" quicker if they hit e.g.
// a wall. At the same time we have to prevent that driving
// backards gives an advantage (see m_max_speed_reverse_ratio),
// and that a potential slowdown due to the terrain the
// kart is driving on feels right. The speedup factor on
// normal terrain (power_reduction/slowdown_factor should
// be 2.5 (which was experimentally determined to feel
// right).
float f = 2.5f - 3.8f*(1-m_power_reduction/stk_config->m_slowdown_factor);
// Avoid that a kart gets really stuck:
if(f<0.1f) f=0.1f;
m_vehicle->applyEngineForce(-engine_power*f, 2);
m_vehicle->applyEngineForce(-engine_power*f, 3);
}
else
{