What is the best way to check whether player standing on the ground?

I’m making a custom character controller(using humanoid) to make movement smoother.

at first, I detect it using a checking part, but It made player climb on walls.
and then I do it with humanoid.FloorMaterial, but it caused player to jump twice.

So, I know there are some ways to do it, but I don’t know what is the best way for me.

I want the speed to be maintained while player is in the air (like air strafing), so I check this every frame. If you know better ways, please tell me. thank you!

1 Like

Could you elaborate on what you mean by this?

I do it with humanoid.FloorMaterial, but it caused player to jump twice.

I would personally use Humanoid.FloorMaterial for this.

1 Like

at first, I detect it using a checking part, but It made player climb on walls.

Did you turn off collisions for the part?

Also raycasting might work
Raycasting | Documentation - Roblox Creator Hub

1 Like

I mean, the FloorMaterial property doesn’t change immediately so the player could do a double jump.

For more precision and proper differentiation between grounds and walls. (and other objects)

You could fire a Raycast downwards and make use of Collision Groups. One of the properties of RaycastParams allows you to set the CollisionGroup. You could also check the raycast result to see if hit part is part of your Ground CollisionGroup or not (using the CollisionGroup property of the part).


[RaycastParams]

You could also check the direction of Normal within RaycastResult. The closer the Y component is to zero, the more vertical the surface is. This can be used to differentiate between ground, walls, and ceilings. Check the documentation for more info about it.


[RaycastResult]

Another way would be to use CollectionService to tag ground parts and then use FilterDescendantsInstances (of RaycastParams) to only check against ground parts.

1 Like

Did you turn off collisions for the part?

Yes I did.

I know, but will doing raycast every frame cause lag? or I’ll need to find another way to make air-strafing

It’s not going to lag, atleast if done locally :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.