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

you helped me but my ui looks like this:

but it works !
but oh wait i can do the exact same thing but easier, more consistent in controls and less buggy by putting a ceilling so no. {its a fail !}

I’m confused. Does it work? What do you mean by ceiling. I never truly understood the concept. If it’s not working then how is it not working. What do you want to happen?

Does your scene have a ground or are there gaps. If there are gaps without a ground then the ray cast has nothing to test against and won’t change the variables. If there are gaps with no ground then what do you want to happen?