, a first-person character walking into a wall at a shallow angle slides perfectly along it, with velocity dropping to very low values (like 0.xx). I want to achieve movement similar to Resident Evil 7, where the character effectively “sticks” to the wall when moving into it from any direction and cannot push further into it. To move again, the player must either press one of the other movement keys or turn the camera away from the wall. I’d like to know how to implement this. You don’t have to write the entire system—just pointing me in the right direction would be great. Ideally, I’d like to use Blueprints, but I’m open to C++ if necessary. I hope I’ve explained the question clearly.
There are some plugins provided by epic or 3rd parties i don’t remember exactly that help do this. A simple system is to use a line trace and calculate the distance between the player and the wall, make sure the line trace goes forward depending on the direction. You can then use a curve float and multiply the value depending how close the player is to the wall. if he closes the distance the output x or y value from the curve float can be multiplied to the speed of the player.
One thing you could do is make a trigger box that wraps around walls, give the trigger actor a tag like StickyWall, and on begin overlap for your player capsule, get tags from other actor, and branch off has tag StickyWall, if true, set a bool (“bStickToWall” maybe) and change max walk speed. To soft aattach player to wall do a trace towards wall, break results, drag oh hit normal and use make rot from x, then get Right Vector from that and save it as var. Then on move input for strafe, do select vector into world direction using the sticky bool and plug saved right vector into a. Then strafe keys should move parallel to wall.
And, of course, to get away from wall, use on end overlap, get other actor tag again, and if it was stickywall, set sticky bool back to false. I was in the process of wiring up a demo, but a thunderstorm rebooted my pc..