_velocity.y = move_and_slide(_velocity, FLOOR_NORMAL).y
How does this create the results we see ?
It works just fine, but I need to understand exactly what I'm doing.
Thank you in advance for any help.
In short, this line allows us to reset the character's vertical velocity to 0 when they hit the ground and prevents them character from falling through the floor.
Here's a more detailed explanation.
The move_and_slide function handles collisions and returns the resulting velocity of your character.
For example, the character is falling and they hit the floor, this will return a velocity vector with the vertical component set to 0.
We apply gravity to our character every frame to make them fall. When they are on the ground, gravity keeps them in contact with the ground every frame, allowing Godot's KinematicBody2D node to know the character is on the floor.
Now, we need some way to reset the vertical velocity when the character is on the ground because otherwise, the value would increase until it becomes so large the character would move through the floor.