There’s already a perfectly accurate way to do this using the IsTouching calls. You can filter by contact direction, layer-mask (etc) to detect ground, walls, ceiling etc. No need for spatial queries and it comes down to a single line of code.
You can see an example of it here with links to the GitHub examples repo:
Side note: Please don’t necropost . This thread was resolved.
Thanks.