I am working on a ledge grab component and stuck on a specific little pain point.
- If I detect something about where a ledge would be, I do a sphere trace at the point of impact to see if there is room for the player capsule (crouched).
- I’ve found after some testing I’d like to give a little leeway and allow the player to grab if the initial sphere trace (directly in the middle of the impact) doesn’t find room for a player, and they are actually missing a viable location with room by one capsule radius width to the right or the left.
- To this end, if the main center trace fails to find room for the player, I try to send out one to the left of it, and if that fails, one to the right of it. Order on the latter two is currently arbitrary.
- I’m taking the normal from the original impact in step 2, multiplying by the capsule radius, or by negative capsule radius, for right and left respectively. This creates my Offset vectors that get added later.
- I’m seeing it kind of work, only perpendicular to how I want.
(Any of this only happens when the player is airborne, these are just persistent debug draws after landing)
The player is in the orange box (it is a first person project), and the center sphere trace is in the purple box. The second example (right side of image) is with the player turned ~90 degrees to their right, facing a different side of the same wall actor.
Basically the two extra traces I’m trying to do are coming out parallel to the player and perpendicular to the wall. I am trying to accomplish the reverse and am not totally sure how to manipulate the vectors correctly.
I still have verifying that the object actually has an up facing side on my todo (which would execute before this check for player room and stop if there is no up facing side), but I am trying to tackle this problem for now.