Hi guys,

I’m posting cause I looked everywhere to find a solution, tested everything and I didn’t find a solution.

I’m making a simple car network, car going from waypoint to waypoint.

My car is just a rigidbody, with sphere colliders on the wheels, they are facing Z and Y is Up.

I let the physic(rigidbody) and gravity tacking care of the X and Z rotations.

Now I want to face the target waypoint, but it seams that I’m not having the good solution, cause sometime the car is going crazy.

I think I would like to end up **with an angle to turn in Y**, but **whatever the rotation in X and Z**, I guess this is the solution to after rotate my car from this angle.

Here is the code I have so far:

Thank You for your Help

```
Vector3 dir = (new Vector3 (targetNode.transform.position.x, targetNode.transform.position.y, targetNode.transform.position.z) - new Vector3 (transform.position.x, transform.position.y, transform.position.z)).normalized;
dir.y = 0;
float direction = Vector3.Dot (dir, transform.right);
var angle = Vector3.Angle (new Vector3 (transform.position.x, 0, transform.position.z), new Vector3 (targetNode.transform.position.x, 0, targetNode.transform.position.z));
Vector3 MyRot = rigidbody.rotation.eulerAngles;
if (direction > .1f) {
rigidbody.rotation = Quaternion.Slerp (rigidbody.rotation, Quaternion.Euler (MyRot.x, MyRot.y + angle, MyRot.z), Time.deltaTime * turnSpeed);
}
if (direction < -.1f) {
rigidbody.rotation = Quaternion.Slerp (rigidbody.rotation, Quaternion.Euler (MyRot.x, MyRot.y - angle, MyRot.z), Time.deltaTime * turnSpeed);
}
//Add Gravity
rigidbody.AddRelativeForce (-Vector3.up * 5000 * Time.deltaTime);
//Add speed and clamp speed
if (rigidbody.velocity.magnitude < speed * .3f)
rigidbody.AddRelativeForce (Vector3.forward * speed * Time.deltaTime, ForceMode.VelocityChange);
```