How does Roblox's humanoid detect if you are grounded

this problem actually concerns the Godot game engine but the answer would be extremely hard to get from any godot related forum

  1. What do you want to achieve? Keep it simple and clear!

i am basically recreating Roblox’s humanoid controller in Godot

  1. What is the issue? Include screenshots / videos if possible!

I have camera control working (orbit, shift lock, first person, angle bracket keys), basic movement, and character alignment, i am stuck on replicating jumping, making the player impulse upward is the easy part, the part where you check if the player is on the floor is surprisingly difficult.

I cant simply use a single raycast pointing downwards, because if i am standing just over the edge of a cliff, the raycast will no longer be touching the floor, despite me not falling down, and obviously standing on the cliff.

I cant use Godot’s Area node, because it cant detect StaticBodies (all “anchored” parts will be using a “StaticBody”), i cant use RigidBodies because that would be very performance intensive, as there will normally be thousands of parts ever present in the scene at a time for the intended use case. Not only that but things like tightropes wont let you slip (walking on a part that has a width of 0.5 or lower will make you more easily slip and sink down the rope).

  1. What solutions have you tried so far?

i have looked for literally months to find a solution, nothing has been successful in the slightest

I want to clarify that it needs to be very presice to the original, so that a godot port of this: JToH - Citadel of Void all jumps (Part 1 out of 7) Floors 1, 2 and 3 (CUTS) - YouTube will play out accuratly to the original, and no, im not recreating the game in the video.

In the Humanoid there something called Humanoid.FloorMaterial. When the character’s feet isn’t touching a surface it is set to nil, and if it is touching then it will display the floor material.


You can have a script to change the walking sound when on certain materials by adding a local script into the character such as.

local Humanoid = script.Parent:FindFirstChild("Humanoid")
local Walk = script.Parent.HumanoidRootPart:FindFirstChild("Running")
while true do
	wait(.25)

	if Humanoid then
		if Humanoid.FloorMaterial == Enum.Material.Grass then
			Walk.SoundId = "rbxassetid://252965149"
			Walk.PlaybackSpeed = 1.5
		end
		if Humanoid.FloorMaterial == Enum.Material.Concrete then
			Walk.SoundId = "rbxassetid://833564121"
			Walk.Volume = 2
		end
		if Humanoid.FloorMaterial == Enum.Material.Plastic then
			Walk.SoundId = "rbxassetid://833564121"
			Walk.Volume = 2
		end
	end
end
10 Likes

no, im not interested in detecting if the humanoid is grounded or not in roblox, im trying to figure out how it detects if the humanoid is grounded under the hood, since i am trying to recreate the roblox character controller in godot

Maybe something changed, but I’m seeing that when the humanoid is in midair, FloorMaterial is set to Enum.Material.Air rather than nil.

1 Like

I know this is old but whatever, there are multiple ways ground detection can be achieved, one method is checking if the players capsule collider is touching an object, or you could cast a ray alternatively a spherical cast, to detect whenever the player is mid air or grounded

1 Like

Given you’ve used raycasts, you could always increase the number of raycasts from 1 to 4 and point them at the extremes of the “feet” part of the player object. Alternatively, you could just add tight hitboxes to all the parts of the player model and determine if those boxes intersect any other hitboxes in the map every frame.