# Steering Overcompesation

 0 I have a car and trying to implement an AI System however when I tell the car to travel to a certain waypoint the car begins to overturn due to the drifting and makes a wave continuing to overcompensated the turn. I need to smooth out the turn. Any ideas how to make a gradual turn to a point. ``````Vector3 target = waypoints[currentWaypoint].position; Vector3 moveDirection = target - transform.position; Vector3 localTarget = transform.InverseTransformPoint(waypoints[currentWaypoint].position); //Calculate the angle for the car tires to travel m_targetAngle = Mathf.Atan2(localTarget.x, localTarget.z) * Mathf.Rad2Deg; if (currentAngle < m_targetAngle) { currentAngle = currentAngle + (Time.deltaTime * steeringSpeed); if (currentAngle > m_targetAngle) { currentAngle = m_targetAngle; } } else if (currentAngle > m_targetAngle) { currentAngle = currentAngle - (Time.deltaTime * steeringSpeed); if (currentAngle < m_targetAngle) { currentAngle = m_targetAngle; } } aiSteerAngle = Mathf.Clamp(currentAngle, (-1) * m_currentMaxSteerAngle, m_currentMaxSteerAngle); `````` more ▼ asked Jul 08 '12 at 08:17 PM maryrall 1 ● 1 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

Be the first one to answer this question

By Email:

Topics:

x956
x416
x286
x48
x30

asked: Jul 08 '12 at 08:17 PM

Seen: 321 times

Last Updated: Jul 08 '12 at 08:17 PM