Hello!
I am implementing a dodge feature into my third-person action project by using a short line trace and interpolating the character location along it’s length (using SetActorLocation). Now, while this works fine by just drawing a single horizontal trace from the capsule component and having that be the track, the problem arises once the character dodges on the slightest slope; the line trace will move the character along a still horizontal direction, leaving him off the ground if dodging downhill or not going quite as far as they should if hoing uphill.
I would like to make it so that the end of the horizontal line trace is always the same height from the ground as the beginning of it (the collision capsule’s half-height, I believe) to make the trace always be parallel to the terrain.
The idea I came up with has me shooting a vertical line trace, starting from where the end of the horizontal trace will be and going straight towards the ground
and somehow using the hit distance or hit location of that vertical trace to modify the end of the horizontal trace so that it is always the same distance away from the ground, but I can´t figure out how to implement such a feature for the life of me.
Any of you math-savvy fellas could lend me a hand? I’d greatly appreciate it.
Thanks tons.
My BP code attached here:
First LineTrace is the vertical one, second is the horizontal, they’re one right after the other, the actual movement logic is offscreen but I wouldn’t believe its relevant.