Hey everyone. I'm new to Godot, so I'm sorry if this is a dumb question. I am making a basic platformer to get used to the engine, as I come from Unity. I created a CharacterBody2D and I tried to give it gravity. I wanted to know if the character is touching the floor so that gravity doesn't apply when this is the case. However, is_on_floor always returns false; even when my character falls into a StaticBody2D.
This is the code I'm using:
extends CharacterBody2D
const SPEED = 300.0
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
if not is_on_floor():
velocity.y += gravity * delta
move_and_slide()
print(is_on_floor())
And my scene currently looks like this:
Thank you for your help!