Detecting when a player is over a crack, not falling? Custom humanoid

In my game, I have made a custom character and a custom controller for it. I’ve been working on making custom HipHeight, but I just can’t find a way to detect when a player is over a crack. I could add an invisible block over the cracks, but that’s not very dynamic and I want the character to work well in almost any environment (since I may release it for public use in the future).

image
Pictured is the root part of the character (red) with 4 attachment points(green), from which I raycast down to the floor. Since there can always be points where the rays hit the floor too far, the character falls as it thinks there is no floor underneath it, when it should walk on the cracks.

How could I fix this? I’ve considered making a small region3 and checking what parts intersect with it, but I’m running this on Heartbeat and I don’t think that would be very viable.
Tell me your ideas if you have any!

Thanks.

3 Likes

You may be interested in looking at the source of Luanoid, a custom humanoid replacement built by one of the most brilliant engineers I know, @LPGhatguy. He works on the Lua Core team at Roblox and presented Luanoid for his 2017 hack week project. Here is the video of it in action.

Looking at the source code, mainly castCylinder.lua and walking.lua, I see that he got ray casting to work properly for him. He casts rays in a sunflower pattern and biases the ones in the direction that is being walked towards. I’m not sure how often he does this, but I suspect that nice results can be attained at walking speed without doing it every frame. Making it speed dependent makes sense to me.

Region3s can’t be oriented to match the contact area of a humanoid’s legs, but perhaps a slightly smaller part would work well. Bar that, there is my GJK that you could use to test a custom convex hit box for (you could even smoothly warp it due to movement). Options, but Luanoid is a proven method.

2 Likes

Ooh, I’ve seen Luanoid before and I’ve messed with it a bit, but it didn’t occur to me to check it to see how they handle stuff. I’ll take a look at these ideas tomorrow - been stuck on this for a while.
Thanks for your help!

I appreciate the compliment, but most of the interesting raycasting work was done by @ContextLost, a brilliant engineer on the physics team! :smiley:

3 Likes

There’s no real secrets in Luanoid, just a lot more casts. If they’re short they’re not as expensive as you might assume.

In an ideal world we would support shape casts which would let you cast down in a pattern that guarantees no gaps in coverage, but our engine doesn’t support cast volumes at the moment so you’ll have to make due with cast rays. In Luanoid I just did ~30 short casts to make up for the lack of shape casts. You can probably get by with less than that.

With the right cast pattern and the right set of level design constraints, like just avoiding gaps that that your cast pattern might miss, you might be able to get results that are just as good anyway.

4 Likes