# How to detect my car is drifting or not ?

I am making a drift game. I want to add score points and compliments on during the car drift. How can i detect now my car is drifting and now my car is going straight i-e not drifting ?

Compute the dot product among the velocity vector (Rigidbody.velocity) and the car’s heading (Transform.forward):

• If result is 1, the car is just driving normally.
• If result is 0, the car is sliding laterally.

Values in between can represent the amount of “drifting” of the car. You can also get the exact angle of drifting in degrees, and give more points with more angle and velocity:

``````float driftValue = Vector3.Dot(GetComponent<Rigidbody>.velocity, transform.forward);
float driftAngle = Mathf.Acos(driftValue) * Mathf.Rad2Deg;
``````

try this:

`Vector3 driftValue = transform.InverseTransformVector(rb.velocity); _driftAngle = (Mathf.Atan2(driftValue.x, driftValue.z) * Mathf.Rad2Deg);`

it returns the positive and negative angle of drifting value.