How would I prevent my character from going into a wall while prone?

Hello,

As the title says, I have a problem with my existing prone system. Basically, while my character is prone, the character mesh can go through a wall. I know and expected this to happen because of how Unreal’s collision management works with characters (since it only goes by the collision capsule unless you want a complete mess), but I was wondering if anyone had any ideas for how to prevent the character from doing so, while simultaneously treating this collision as the capsule would (i.e. if you’re up against the wall, but moving diagonally, it will slide slowly against the wall).

I have a couple of ideas prototyped in Blueprints, one of those being to allow the developer using my framework to add box components around the mesh with a “-checkprone” tag, and to stop up movement input completely should one of those boxes hit, but A) that’s not the most elegant solution for what is to be a very AAA-level framework, and B) camera rotation becomes very frustrating to deal with if the pawn is also supposed to rotate with the camera (although this issue could probably easily be dealt with just by switching some booleans).

If you have any ideas I will happily take them into consideration. Feel free to send Blueprints as well and I will do my best to translate them to C++ (which is what I have been doing so far).

All help is appreciated, and thanks in advance!


Note in the image above: I do have the collision sizing working for the capsule, so when I use the prone function it does indeed shrink as needed. This is just an example with a fixed prone animation because with that function it does the same thing.

1 Like

Hi there,

You can use sphere traces/ capsule traces to block movement input in certain directions, and also to check if a given area is suitable to enter the prone state.
Perhaps this video can help you out.

1 Like

You can spawn an additional collision shape with the same collision setup as the capsule. The additional shape should lie flat on the ground and grow up to the size that is the character + legs, arms etc.

Might work with players but testing on my AI, the additional collision capsule does nothing when they back into obstacles.

I keep forgetting how exactly the collision is handled by external systems as currently I have tons of other stuff to look at. About a month ago I ran into a situation with UE5.2 which I attempt to remember correctly. My collision was not working properly on a seemingly simple asset (pawn with custom simplified movement component) which moved through walls. What (I think) I found was that the collision component has to be the root component of a pawn, and did not work with a complex collision, say, if the pawn used a static mesh with its own collision, it would pass through walls regardless of the collision setup and collision settings. What is supported, is to use a simple collision such as capsule just like unreal’s example character does.

This situation leaves the original question of this topic without answer (and makes my previous comment invalid). In physics situations however, I had been able to use a characters complex collision in old projects back on UE4. It gets a bit complex and certainly tangled in certain engine systems their code.

1 Like

Idk if it’s a viable answer to recommend something off the marketplace, but this plugin is great and I’m using it for just that effect.

Well documented and an active discord community.

Ah, that’s my specialty!

Some time ago I tried to offer a PR about multicollision movement sweeps. Unfortunately it was never even looked at (but I still use it in my fork).

The short story is, this recommendation will not work:

It will not work, because in UE, primitive components are made in such a way that they only sweep themselves during movement. And all actor movement is really only a wrapper around the root component movement. (I’m talking at the level of “SetActorLocation”, so it’s “movement” in the most basic sense, not a movement component)

So, if you add multiple collision shapes, other actors can collide with all these shapes, but if the multi-collision-shapes actor moves, they themselves will only use their root component’s collision, which is the opposite of what we need of pawns (usually, pawns move around in a motionless world).

(Note how I explicitly say “primitive components”. It’s a very basic class that is in the inheritance chain of most relevant components, so there are very few ways around modifying the engine code, aside from duplicating the whole primitive components stack: static meshes, collision shapes, etc)


Therefore, as others have pointed out, OP may have to implement manual traces in order to limit movement directions too close to walls, and limit crouch activation (or rather, I’d recommend automatically nudging the pawn to the side when crouching too close to an obstacle. Because nobody likes their inputs randomly failing for no discernable reason)

In my opinion however, this is an other solution, a bit unorthodox: You could rotate the entire pawn sideways while the character is crouched (or rather, the capsule, but I’m guessing this is equivalent to rotating the entire pawn). Of course, you need to “unrotate” the camera, and implement your own movement component to handle the inputs in this rotated state.

Whatever you chose, it’s bound to feel amateurish: The first option may feel more straightforward, but as soon as you introduce external forces/hits into your gameplay (pushback from explosions, a dodge roll, a bullet hitting the legs, etc..) you will start making an exponential amount of edge-case management code, because you are not doing a true collision, only an emulation.