I was doing car tutorial and I found steering control code there …But the problem is it take turn drastically when i take input as
Mathf.Clamp ( Input.GetAxis(“Horizontal”),-0.5,0.5);
Please help me to make it steering proper in my car racing game…Below is the reference code
if (steerInput > 0.0f)
{
steering += (steerInput * 30) * Time.deltaTime;
if (steering > steerInput) steering = steerInput;
m_steerR = steerMax * steering;
if (m_steerR > m_steerAngleMax) m_steerR = m_steerAngleMax;
m_steerL = Mathf.Rad2Deg * Mathf.Atan(1.0f / (Mathf.Tan((90 - m_steerR) * Mathf.Deg2Rad) + B / H));
}
else if (steerInput < 0.0f)
{
steering += (steerInput * 30) * Time.deltaTime;
if (steering < steerInput) steering = steerInput;
m_steerL = steerMax * steering;
if (m_steerL < -m_steerAngleMax) m_steerL = -m_steerAngleMax;
m_steerR = -Mathf.Rad2Deg * Mathf.Atan(1.0f / (Mathf.Tan((90 + m_steerL) * Mathf.Deg2Rad) + B / H));
}
else
{
steering = Mathf.Lerp(steering, 0, Time.deltaTime * 30);
m_steerL = steerMax * steering;
m_steerR = steerMax * steering;
}