What is a 'normal' in ControllerColliderHit?

I am trying to writting a script, that detects when the player collides with a floor. To do this, I am referencing the Character Motor which is a part of the Standard Assets.

While studying the code, I ran into this line:

groundNormal = hit.normal;

What is ControllerColliderHit.normal, and how is it related to checking if an object is on a floor?

A normal is a vector perpendicular to a surface at a particular point:


Each of the arrows in the picture is a normal for that specific point. ControllerColliderhit.normal will be the normal at the point of contact. You are probably trying to puzzle out this line:

if (hit.normal.y > 0 && hit.normal.y > groundNormal.y && hit.moveDirection.y < 0)  

Breaking it apart:

hit.normal.y > 0

This will evaluate to true if the normal is facing upwards. So the collision will have to be with a surface that is facing upwards.

hit.normal.y > groundNormal.y

This will evaluate to ture if the hit surface is facing more upwards that the previous calculated groundNormal.

hit.moveDirection.y < 0

From the reference: “Approximately the direction from the center of the capsule to the point we touch.”