Wall-walking/hugging System help


I am trying to create a wallhugging/walking system essentially identical to the one found in the 2003 game Indiana Jones & The Emperor’s Tomb, wherein pressing an input next to any wall surface will attach the player to the wall and allow smooth movement around corners. (See linked video for reference.) My first instinct would be to do this with a line-trace of some kind, however I’m having a really hard time figuring it out. I can get the player to attach to a wall by sphere-tracing on input-pressed and constraining the player movement to a plane set by the normal of the impact point. And it works in theory, however the system quickly falls apart when trying to round corners. I can almost make it work on inner corners by way of line-tracing back and to the right/left of the player and updating the planar movement & rotation based on that line-trace, but it’s very broken and glitchy. I have absolutely no idea how to approach the rounding of outside corners. (See the second video reference) I’ve attached 2 screenshots of my blueprints. One portion is firing off the button press, and the other portion is firing on a tick only when player is attached to the wall. I’m not so concerned about the animation side of things for the moment, unless someone savvy thinks it could be done with root motion or something.(I was going to use a blendspace rather than montages etc. as the player should maintain full control of movement while attached to the wall). I would be very curious to know if anyone has an idea to how this could be done properly, and would appreciate any suggestions.

Thanks in advance!

Reference for what I want: https://drive.google.com/file/d/1BJZqdNDv8fbMHLnTTpM77CaMw2rKvcCb/view?usp=sharing

The messy mess I currently have: https://drive.google.com/file/d/1Wju4-DoHZAdkAau4q_dxQequiF7895aT/view?usp=sharing

void AWalkOnWallsTut3pCharacter::DebugLocalAddRoll(float val)
 FRotator NewRot(0.f, 0.f, 0.f);
 GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Yellow, FString::FString("Yaw before ") + FString::SanitizeFloat(GetActorRotation().Yaw) + FString::FString("Pitch before  ") + FString::SanitizeFloat(GetActorRotation().Pitch) + FString::FString("Roll before ") + FString::SanitizeFloat(GetActorRotation().Roll));
 NewRot.Roll = val;
 GEngine->AddOnScreenDebugMessage(-1, 5.0, FColor::Yellow, FString::FString("Yaw now ") + FString::SanitizeFloat(GetActorRotation().Yaw) + FString::FString("Ptich now ") + FString::SanitizeFloat(GetActorRotation().Pitch) + FString::FString("Roll now  ") + FString::SanitizeFloat(GetActorRotation().Roll));


AddActor local rotation after tracing did the work in previous versions of UE4 maybe it will happend the same in Newest UE4 i could walk on walls.Walk on walls, Physics spider in UE4 - YouTube even with set rotation should be enough.

Well my help here it is say that it is possible.

I would rethink the approach a bit.

First of.
You already have a method of detecting what is being connected with - the capsule.
Any default character class has one. It’s actually useful in this case since you can use it to detect the walls collision.

Second, any piece of stuff in the game should cause an overlap or hit event with the capsule.
This means that if the part of the wall you are interacting with changes, you could also quickly change the normal you are interacting with to make calculations.

because this is done on a moving character, you can probably ignore the fact that collision on being overlap events aren’t always accurate. They will be accurate here because the capsule is moving against the wall, so it should generate hit and overlaps as it goes anyway (if not on the first time, on the next 3 or 4 which are calculated in a millisecond while you move).

that solves one part - sticking yourself to a wall. You can re-work all that code you have and simplify it using that information.

Now the corners.
So, for animations to be smooth you need to know about the corner beforehand.

2 solutions I can think to this, and it depends on your game and how you work.
solution 1, every corner gets the same tag that the character BP will check in order to know and prepare.
Solution 2, you run a sphere check on the direction you move in about 1m ahead, and once that sphere check is false you know to prepare for a turn.
you can actually combine Both methods, and allow the character to prepare to get out of the sideways walking animation into a regular animation if the wall ends and you have no corner tag (think of a doorway for instance).

Anyway, based on the information you have above, you can prepare a turn, and rotate your character or the root bone perhaps to match the angle of the new wall where the other system can take over again.

Theoretically, if you misslabel a wall to be a corner, you should get your character into whatever animation set you have to prepare for the turn, and then abort and go back to wall walking because the overlap on the capsule detected the wall again.

Anywah, that’s my theory and how I would go about implementing it. (Which I need to, eventually).