Reliabilly checking if a character is standing on a platform with raycasts

Hello, recently, I have been re-designing an anti-cheat that I made a while ago. As part of my fly detection mechanism, I require some way of reliabally know if a player is standing on a platform.

My initial idea was to shoot a raycast from each corner on the bottom of the character’s torso in order to see if it could detect any sort of platform. However, I realized that there would be one problem with that: If the size of the platform is smaller than the character’s torso, then there is a chance that the raycasts would not detect the platform, thus creating a situation where the anti-cheat believes the character is mid air when it is really not.

To illustrate this issue, here is a diagram (looks repulsive I know, haha)

RED = RAYCAST
BLACK = PLATFORM
ORANGE = BOTTOM OF PLAYER TORSO

Any suggestions on how I can get about this issue is appreciated.

1 Like

I think this may not be a reliable way to detect if a player is flying since a player may jump in the air causing the rays to shoot into nothing and think the player is moving on air. There may be better methods of checking if a player is flying. I personally haven’t done much anti cheat work in my scripts since I normally put boundaries where normal players can’t go and if the player touches those boundaries they get teleported back.
I think you could try detecting the speed of the player and their position. If player.PrimaryPart.Position.Y > (This value would be the height that it is obvious a player is flying, such as if their height was greater than 50 and most players could only jump to height 40). Then the player is flying and they would get kicked.

1 Like

I have already figured out speed detection mechanisms as they were quite easy to do. Thanks for your reply though.

1 Like