Line trace based on results from another line trace for ledge detection

Hi everyone, I’ve been trying for a while now to come up with an accurate ledge detection system. I figured I need two traces so far, one that projects out from the player, and a second trace that ends at the collision point of the first trace to find the top edge of a wall. It’s quite hard to explain so I drew a little diagram:

So no matter how close the player gets to the wall, the second trace will always collide at the goal in the diagram. I’ve tried using the impact point of the first trace to calculate the start and end of the second trace, but this only works for when the first trace is actually colliding (a floating platform for example isn’t detected). I’ve tried to make it so the second trace always draws regardless of whether or not the first trace has collided without using the impact point, but because I’m really new to vector math and I’m still finding my way around the Unreal Engine, it’s not quite working out for me. This is what I have so far for the first trace in the ThirdPersonCharacter blueprint of the example project:

And here is what I have for the second trace which follows from the first trace in the same function (excuse the mess):

Thanks in advance :smiley:

Usually people makes few sphere/capsule traces in forward direction. every next trace is higher than previous. to detect when capsule passes. Then make trace from above to detect edge.

Hello!

You can get the mesh bounds from the first trace

Oh, how could I go about doing that?

Thanks for the answer! This sounds like it will work but I can’t help but think it might be a bit inefficient and hard to manage.

See these!

Would this work for more complex models such as a rocky cliff-face or moving objects?

Yes it works for static mesh, not sure if it works for movable or everything else.