You could do get_collider().get_pos()
and if the y
coordinate is greater than the player's y
, then the object is below. However, that won't work well for you if you have vertical obstacles/walls, so you'll also need to use get_collision_normal()
to ensure it's a horizontal surface.
A simpler way to do this is to add a RayCast2D
pointing downward. Then you can do if raycast.is_colliding()
to allow jumping.