The dot product has two nice properties for collision avoidance. The dot product is closely related to the cosine of the angle between two vectors.
The dot product of a unit vector A and a second vector B of any non-zero length, the result is the length of vector A projected in the direction of vector B.
So as you can see in the image; if the angle is greater than 90 degrees, the dot product will be negative. So, the dot product has to be a positive value or there will be no collision. Most likely in your code/tutorial the dot product is used to check if the objects are heading towards eachother (maybe based on a "viewcone" or something similar- for example a dot product of >0.5 equals a cone of 45 degrees). This is the first property: check if the objects are actually heading towards eachother by evaluating the angle between them.
Once decided a collision is likely based on the directions the objects, the next property comes into play:
The relPosition and relVelocity are is used to project the velocity vector onto the position vector:
float timeToCollision = Vector3.Dot(relativePos, relativeVel);
This line basically projects the Velocity (A in the image) onto the RelativePosition (vector pointing from the first agent to the 2nd agent).
Then the result is divided by the
relativeSpeed * relativeSpeed (since the two objects both have their velocities turned into one relative speed value), to calculate the actual
Note that this calculation does not mean the objects will collide! It merely calculates the time where the two objects are the most close to eachother during their trajectories (the variable name may be confusing you here!)
This is where these lines comes in:
float distance = relativePos.magnitude;
float minSeparation = distance - relativeSpeed * timeToCollision;
The minimal Separation is the distance between the two objects at the time of the closest approach. Remember
relativePos is actually a vector from object A to B; the magnitude is the current distance. Shorten the distance by the distance travelled during the calculated timeframe
relativeSpeed * timeToCollision and the result will be the minimal distance between the objects during the trajectories.
Now if the minimal distance is smaller than the sizes of the objects they will collide and the agent must take an evasive action.
The image is taken from the Wikipedia page 'Dot product'.