How do I implement ledge detection using Raycast?

Hello! I am making a 3D platformer game and I want to add ledge climbing system just like from Super Mario 64?

I tried to find a good youtube tutorial for ledge climbing system, however none of them answers my question since most of them uses box collider for ledge detection. I don’t want to use box colliders, instead I want to try detecting ledges using raycast hit.

Is there a possible way for doing this?

I created a solution myself for my parkour system I made earlier. It’s somewhat simple in concept, but is probably tedious as you are hoping for it not to be.

-Basically, every frame, I do a front scan from my character using cube cast.

-If there is a hit, then it shoots about 6 raycasts (adjustable), from just above the floor to above the top of the head (for jumping high ledges). This determines if there is higher ground (ledge) ahead of you and its basic height.

-Also, if there is a hit,
a) it will create a new raycast above and beyond the highest raycast hit point and shoots down to determine the exact height.

b) If they all hit, it’s a wall, no jump

-Then I use “animation target matching” to throw my jumping character up there.

-Another ray is in front of my character and pointing down. This is a ledge detection from on top of the ledge going down.

-And two more rays are to the side of that one, also pointing down. This helps determine if a ledge is just off to the side.

I use all these as “sights” for my character to use and trigger animations and movement.