Jummit Okay, here is what I've done with a raycast:
var really_on_floor = ground_check.is_colliding() == true
velocity.y = velocity.y - (gravity * delta) if not really_on_floor else 0.0 #This is the gravity code!
if really_on_floor and Input.is_action_just_pressed("jump"):#Checking if the player pressed jump
velocity.y = jump
It works to some degree but, it has it's own set of problems. The only way this works smoothly is if only the tip of the raycast is touching the floor. If the raycast is through the floor, the jumping gravity will stop as soon as the code notices that the raycast is still touching the floor. This means that I have to smash the jump button repeatedly until the controller can get off the floor probably. Also, I don't know of any way to prevent the raycast from going through the floor when moving up or down slopes.
Edit: This system works very well most of the times. Sometimes it behaves janky when I run the game and I don't know how to fix it.
Edit again: Okay, here is what works best for me right now.
var still_is_on_floor = ground_check.is_colliding() == true and not is_on_floor()
velocity.y = velocity.y - (gravity * delta) if not is_on_floor() else 0.0 #This is the gravity code!
if (is_on_floor() or still_is_on_floor) and Input.is_action_just_pressed("jump"):#Checking if the player pressed jump
velocity.y = jump