Is there a standard solution for not letting the player fall of cliffs?

I found Pawn.bCanWalkOffLedges and some other variables. But I’m not sure how they work. I have my own system that doesn’t work very well. It traces in front of you and checks to see if there’s ground under your feet if you go there. It’s touchy, and sometimes you’ll get stuck on a box or something, or sometimes you won’t be able to go down stairs. Is there a better, more established way of doing this?

“or sometimes you won’t be able to go down stairs”

I do two traces, ----| , if your system is the same, you can do the vertical trace larguer. My problem with this system is to go up stairs… I need to use something in the stair mesh, like a special tag, so the trace will return free always.

bCanWalkOffLedges actually works quite well. it prevents the Pawn from walking off the ledge but it’s only for cases when the Pawn has bIsWalking set to true
stairs will still work depending on the height of the stairs in relation to the value of MaxStepHeight

so unless you need this also for running there’s no need to reinvent the wheel
if however you need to prevent falling off ledges in all cases you might just want to add blocking volumes

Hey @ thanks! I’ve been looking into bCanWalkOffLedges, and making sure my pawn is walking, and I’ve been playing with LedgeCheckThreshold and WalkableFloorZ. Unfortunately though I don’t have much control over what’s considered a ledge. With LedgeCheckThreshold set to the default of 4, I get stuck on tiny variations in the landscape. With it set to 25, I can walk around and get stuck on small rocks. With LedgeCheckThreshold=10000, it doesn’t seem to change at all and I still get stuck on small rocks. Any ideas?

Thanks so much for pointing me toward the bCanWalkOffLedges solution.

I do that same thing. I set a vector out in front of the pawn, and then trace straight down. If it hits nothing or if the surface is vertical (Normal.Z is too low), then I bounce the pawn backwards.

Do your stairs have a ramp collision mesh, or are they actual steps in the collision? If a ramp, you could adjust your pawn’s WalkableFloorZ. If steps, you could adjust MaxStepHeight. Or if the problem is in your own trace system, adjust how far down you run the trace or the HitNormal.Z threshold.

are you also playing with MaxStepHeight ?

Most of them are using the stairs as collision. With the ramp there are no problem, using hitnormal. So i’m thinking about using a tag in the stair meshes to avoid the front trace.

, I use bCanWalkOffLedges, but the pawn get stuck trying to walk to the sides, one and another time. As I’m using the traces to find the path, the idea is to check the floor and if no floor, the pawn takes it as a wall, so try to find another path at the sides. But, in each trace, the pawn moves forward a bit, and finally falls. I need to improve that, perhaps doing the next trace before changing the direcction. Traces are done every 0.5 seconds, so I need an additional trace before start moving, only after a direcction change.