Between any three waypoints you can create the angle. So for example, lets say the car is between waypoints 3 & 4. Get the direction of waypoint 4 relative to waypoint 3; and also direction of waypoint 2 relative to waypoint 3. Between the two directions you can now find the angle (2-3-4) using Vector3.Angle. I’m assuming in writing this that your waypoints are manually plotted rather than on a math calculated curve (in that case you would already have the angle).

The chance of spin off could then be determined by something like if ((speed * angle) > x){ //run spin off code}. X is the minimum amount needed for a spin off and you could play with this until happy with the results. Once you got something basic, you might then experiment with effects. For example the angle during a spin off could have an impact on rotation of the car; while the speed affects whether the car flips into the air. Likelihood of either and its impact could be affected by use of random numbers and varying the use of physics materials around your track.

These are all very basic ideas and how far you go depends on how comfortable you are with using Unity’s features. But you do need to do some research. These suggestions are rough and only intended as potential ideas for you to investigate feasibility further.

Given the Vector3.Angle question, you don’t seem to be aware there’s actually a cool manual

Vector3.Angle: Unity - Scripting API: Vector3.Angle

Below is some pseudo code - its not a copy and paste (probably not great programming practice and I typed it quickly) but more a guide. Because you’ve not supplied your own code, I’ve made some assumptions about how you implement at the moment.

```
int nextWaypoint = car.GetNextWaypoint();
Vector3 nextV = waypoints[nextWaypoint];
int prevWaypoint = nextWaypoint--;
if (prevWaypoint < 0)
prevWaypoint = waypoints.Length - 1;
Vector3 prevVMin1 = waypoints[prevWaypoint];
prevWaypoint--;
if(prevWaypoint<0)
prevWaypoint = waypoints.Length - 1;
Vector3 prevVMin2 = waypoints[prevWaypoint];
Vector3 prevDir = (prevVMin2 - prevVMin1).normalized;
Vector3 nextDir = (nextV - prevVMin1).normalized;
float angle = Vector3.Angle(prevDir, nextDir);
float speed = car.GetSpeed();
float maybeSpin = angle * speed;
if (maybeSpin > 100f)
{
//Do stuff
}
```

Finally, after a little bit of research (five minutes) found a guy that’s done something interesting and uploaded some source code (Unity project)

Video: Car AI Random Start With Roads - YouTube

Source code: Ryk Waters: Car AI Code [it’s in a rar file, but 7-Zip (free: 7-zip.org - I think?) will open it]

**Warning: Download apps/code/projects at own risk, may contain malicious code, blah blah.**

Youtube and google are your friends; use them!