How do you check if the player is on the ground

I’ve been looking at forums but I haven’t found anything that works. Currently I’m thinking about using body_entered and groups but don’t know the specifics on using it. How would I go about doing that?
Thanks.

Characterbody2d and Characterbody3d have an is_on_floor() function.

2 Likes

Ok thanks, I’ll try that in a bit.

Is there a way to do it with using a rigid body instead of a character body because it breaks my code. Thanks

What do you mean by saying “it breaks my code”?
That function is not available on the RigidBody3D unfortunately. In order to detect the floor, you’d need to use either the RayCast3D or ShapeCast3D nodes to detect the floor underneath your player. It’s a bit more tricky.

1 Like

Sorry for the late reply. Do either know how to do to that or have any helpful source? Thank you

Also I forgot to explain but I originally used a rigid body so the switch causes some issues with my code

Try to look up “Godot RayCast3D” on youtube, there’s plenty of resources there.
Depends how sophisticated of a solution you want to have and what’s your scene setup, but in general, you’d need a RayCast3D node as a child of your Player node, with a ray vector pointing from the player’s feet downwards just a small amount, and checking the collision should give you the answer if the player is on the floor or not.