how to keep a certain distance between character and walls

Hello!

I hope someone can help me, I want to create a distance between my character and the walls/doors/furniture/etc.
Basically, keep a distance for every mesh in the world, except for other actors, those can or should be overlapping the character.

I was thinking about creating a collision mesh in front of the character like so

with the collision presets to keep distance from the meshes. The thing is that it doesn’t work as I intend. I can get as close as possible to the walls in the 3rd person character default map, as if the collision box wasn’t there.

I have the collision presets as “blockalldynamic”

I don’t want to make the capsule component bigger in order to keep distance, I think it might bring some unexpected results (like not touching the floor or something like that), I don’t know also if the capsule component is affecting the collision mesh somehow, since the capsule component is its root, I suspect maybe is inheriting some properties (the capsule component preset is pawn)

If someone knows how to make this work or knows any other way to solve this I would really appreciate it :slight_smile:

Thank you!

2 Likes

A wall isn’t dynamic :slight_smile:

You could try setting it to ‘block all’, and then switching off ‘pawn’.

Thank you :slight_smile: I didn’t know that haha, so I changed a couple of things to test again

I changed the shape of my mesh distance limiter to a cube so it’s more easily to see, also changed the preset to “blockall” and then to custom to ignore pawns, like so:

Now, it kinda works, let me explain: in the 3rd person character default map for UE5 (I’m using 5.4), there are a couple of blocks that have physics enabled, the cube interacts with them, keeps distance, even pushes them and do some crazy stuff (like sending them through the floor if jumped on top)

so that’s kind of what I want, not pushing the objects in the world though (pushing the walls would be crazy) but keeping the distance will be allright, unfortunately, when it comes to walls it doesn’t seem to work:

the cube gets all the way in and the character can touch the wall

another example is this: I have a mesh which its, for this example, a temporary object which I want to keep distance from, again, the cube doesn’t work properly, doesn’t keep the character to come in contact

I also have an example of making the capsule component bigger, that one gets the idea right, but, as I mentioned, it does some crazy stuff haha

the distance with the wall is what I need precisely!

but…the caracter can float haha

So… I’m kinda stumped :frowning: maybe there’s something I’m not seeing? has something to do with the UE version? don’t really know.

Thanks!

Now I remember, the character code only looks at the capsule for the movement collision.

If you want to tweak it, you’ll need to do it in C++, I’m afraid :thinking:

Oh, I see. That’s all right :slight_smile: the project is in C++ actually, I could tweak it if needed, would you happen to know which properties should I adjust? I imagine the capsule component is affecting all of the collision meshes that live under it right? Thank you so much for your kind help :smiley:

1 Like

If you’re using CPP, then you can just edit the capsule, and change it to a block :slight_smile:

1 Like

Thanks! I’ll give it a shot; I remember I googled it previously to adding another collision box if there was a way to changing the default shape of the capsule component, but it seemed like it was pretty hard, but seeing that this option didn’t work I’ll go through the hard path haha, Thank you so much @ClockworkOcean :slight_smile: , I’ll mark it as solved since that seems to be a very good option to keep distance from all other meshes but not other actors!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.