Added separate setting for time back from full steer to

steering straight, which might reduce oversteering somewhat.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11893 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-11-07 23:28:48 +00:00
parent 8334246dd4
commit e3b57e5de0
4 changed files with 29 additions and 13 deletions

View File

@ -370,7 +370,8 @@
steering to extreme left or right.
-->
<turn turn-radius="0:2.0 10:7.5 25:15 45:25"
time-full-steer ="0.2" />
time-full-steer ="0.2"
time-reset-steer="0.1" />
<!-- Speed and acceleration related values: power and max-speed (in m/s)
have 3 values, one for low, medium, and hard.

View File

@ -246,22 +246,29 @@ void PlayerController::steer(float dt, int steer_val)
m_controls->m_steer = 0;
}
const float STEER_CHANGE = dt/m_kart->getTimeFullSteer(); // amount the steering is changed
// Amount the steering is changed for digital devices.
// If the steering is 'back to straight', a different steering
// change speed is used.
const float STEER_CHANGE = (steer_val<=0 && m_controls->m_steer<0 ||
steer_val>=0 && m_controls->m_steer>0 )
? dt/m_kart->getKartProperties()->getTimeResetSteer()
: dt/m_kart->getTimeFullSteer();
if (steer_val < 0)
{
// If we got analog values do not cumulate.
if (steer_val > -32767)
m_controls->m_steer = -steer_val/32767.0f;
else
m_controls->m_steer += STEER_CHANGE;
// If we got analog values do not cumulate.
if (steer_val > -32767)
m_controls->m_steer = -steer_val/32767.0f;
else
m_controls->m_steer += STEER_CHANGE;
}
else if(steer_val > 0)
{
// If we got analog values do not cumulate.
if (steer_val < 32767)
m_controls->m_steer = -steer_val/32767.0f;
else
m_controls->m_steer -= STEER_CHANGE;
// If we got analog values do not cumulate.
if (steer_val < 32767)
m_controls->m_steer = -steer_val/32767.0f;
else
m_controls->m_steer -= STEER_CHANGE;
}
else
{ // no key is pressed

View File

@ -62,7 +62,8 @@ KartProperties::KartProperties(const std::string &filename)
// if everything is defined properly.
m_mass = m_brake_factor = m_engine_power[0] = m_engine_power[1] =
m_engine_power[2] = m_max_speed[0] = m_max_speed[1] = m_max_speed[2] =
m_time_full_steer = m_nitro_consumption = m_nitro_engine_force =
m_time_full_steer = m_time_reset_steer =
m_nitro_consumption = m_nitro_engine_force =
m_nitro_small_container = m_nitro_big_container = m_nitro_max =
m_nitro_max_speed_increase = m_nitro_duration = m_nitro_fade_out_time =
m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_base =
@ -348,6 +349,7 @@ void KartProperties::getAllData(const XMLNode * root)
if(const XMLNode *turn_node = root->getNode("turn"))
{
turn_node->get("time-full-steer", &m_time_full_steer );
turn_node->get("time-reset-steer", &m_time_reset_steer );
turn_node->get("turn-radius", &m_turn_angle_at_speed );
// For now store the turn radius in turn angle, the correct
// value can only be determined later in ::load
@ -584,6 +586,7 @@ void KartProperties::checkAllSet(const std::string &filename)
CHECK_NEG(m_mass, "mass" );
CHECK_NEG(m_time_full_steer, "turn time-full-steer" );
CHECK_NEG(m_time_reset_steer, "turn time-reset-steer" );
CHECK_NEG(m_wheel_damping_relaxation, "wheels damping-relaxation" );
CHECK_NEG(m_wheel_damping_compression, "wheels damping-compression" );
CHECK_NEG(m_wheel_radius, "wheels radius" );

View File

@ -126,6 +126,8 @@ private:
* braking force. */
float m_time_full_steer; /**< Time for player karts to reach full
* steer angle. */
float m_time_reset_steer; /**< Time for steering to go back to
zero from full steer. */
/** The turn angle depending on speed. */
InterpolationArray m_turn_angle_at_speed;
@ -410,6 +412,9 @@ public:
* steering straight. */
float getTimeFullSteer () const {return m_time_full_steer; }
/** Returns the time the kart needs to go back to steering straight from
* full steer. */
float getTimeResetSteer () const { return m_time_reset_steer; }
/** Get braking information. */
float getBrakeFactor () const {return m_brake_factor; }