Hi I posted this in blueprint scripting but after getting a response thought it might apply more to animation.
When running into a wall, my character will stop all velocity and start sliding along the wall. This looks and feels extremely clunky (small collisions will jam my character’s momentum and turn him).
I was wondering how I could change my setup so that the character will keep facing the forward direction and keep playing the running forward animation when colliding with a wall (attached picture to better explain this).
My movement is capsule based and uses a locomotion blendspace that relies on character speed, it seems like I’ll have to make it instead rely on gamepad input? I can visualize how this would work, but I would also like to stop rotating my pawn’s forward vector when I’m running into a wall.
In short, using the dafualt setups you can’t.
the speed is usually taken from the simulated capsule movement and passed into the pipeline for an animation blendspace to use.
to change this, would mean changing the way that speed is changed.
To change this sliding behavour, I would suggest you just align the capsule rotation square to the wall normal you collided on.
it will prevent people from ever being able to slide since every time the collision occurs the rotation is changed.
In character BP, use a linetrace to see if something is in front of you and to get the angle of impact (here you can chose against what type of stuff you want the have this behaviour):
This is can easily be optimized, to prevent a linetrace at every tick. For example, using a box trigger in front of the character to trigger the linetrace only when needed.
Also in the char BP, to stop running when no pressing “move forward”:
Ty for your responses, I will try these solutions but I’m not sure it’s what I’m actually looking for.
With the sliding behavior I don’t actually want to lock the capsule rotation towards the wall normal, I just want to keep the player’s forward trajectory matched with the movement input trajectory.
I tried this solution but this was not reliable at all, there was no real change except for when the character lined up perfectly with the collision object and the speed would spike up to the set value.
I’ve made a few gifs that show exactly what I’m looking at, about half of my static meshes actually allow me to move the character like I was hoping, but half of my meshes make my pawn get stuck.
Gif 1 shows the exact behavior I want (keep forward velocity, doesn’t rotate the pawn and screw up movement input).
Gif 2 shows my character stuck (what I’m trying to eliminate because this behavior feels awful in playtesting).
Gif 3 shows the behavior I want again, but my character gets stuck in the little crevasse (trying to eliminate that).
(Sorry for the gif quality, had to reduce it a ton to upload).
Your solution does work really well, when I hit collision exactly perpendicular to the wall the velocity takes over and it works perfectly, but when the normal force starts rotating my character the collision check turns false… maybe I can figure out how to implement MostHostLA’s idea and keep the capsule rotated towards the movement input?
Edit: Gif 2 is still a problem with your solution, but you’ve definitely put me a step in the right direction so TY
This is going to be my last attempt. With some extra nodes, the character keeps its original impact orientation (the normal force that rotates the character is eliminated) and also allows you to move left and right without rotating the character. At least until no more impact or you stop pressing forward.
Detect impact, save the present rotation, and while “impact” keep same rotation
This just locks the rotation to whatever the impact is, which isn’t really what I’m looking for. But it also doesn’t fix the problem I have in gif 2. There must be something different with the collision impact on the meshes in gif 2.
I really appreciate your help and you’ve given me some good ideas to play with, thanks.
Update: I figured out a solution to combine with what EvilCleric created, I changed my calculate direction in my ABP to use last movement input rather than velocity. I also changed the line trace to a sphere trace and removed the forward impact check (was ignoring getting stuck in corners). Lastly I had some weird rotation stuff going on to smoothly rotate my char during weapon swings so I took that out and will probably have to rework it. Hopefully these fixes won’t break other things, but it looks smooth now. TY for the help guys.
I would suggest a sphiel like the capsule component or even just hooking it directly to the capsule component…
not that it really matters anyway. You wouldn’t get a performance hit unlrss you check continuous detection and constant overlaps.
Hello, I don’t know if you found a solution, but I had a similar problem in my project. Since my blendspaces used the speed of the character when it collided with the wall, its speed dropped and it seemed to slide. I solved it by creating a custom movement state, and instead of using the speed, I use the value of my input axis that I save in a reference in my player, that way the animation does not stop even though the speed drops.