How do i make so the character floats while in air but in a certain height but once if not in ground it falls down 2

how do i make so the character floats while in air but in a certain height but once if not in ground it falls down.

hello so can you give me a step by step tutorial how to make this ?

images:

note that the height can go higher

so i mean if the ground is lower, the character falls down and if the ground is higher, the character goes up

yes the character and touch the ground. character can go down by pressing s and down key and go up with w and up key (combine both for extra speed). if you touch the specific height (2000 pixels above ground) it is like youre touching a celleing, not teleport you down

Can you explain further? This is as close as I can figure. It might not be what you need but it should be a start.

Try me. It uses the arrow keys.
https://gd.games/keith_13579/floating-player

project (click the green [code] and then [download zip]
https://github.com/doug13579/gdevelelop-floating-orb

3 objects, 3 variables, 1 object variable. The shape painter is used just to visualize the ray cast.

image

image