2D Paper Character: Prevent from sliding off ledge

I’m trying to fin a way to prevent the 2d Paper character from sliding off ledges or getting launched away while falling and hitting the corner of a ledge. I know that this is due to the Capsule component which can’t be changed. But has anyone found a work around? Currently I’m testing with a box collision set at the bottom of my capsule to detect my floor but I haven’t been able to find any way to achieve this yet. I can not go into c++.
Thank you.

Hmm Use Flat Base for Floor Checks option fixed the sliding off ledge problem but the Character still gets knocked away if falling on the corner of a ledge… Progress.

1 Like

Oh great, now my character doesn’t keep it’s current velocity lol And Show All Modified Properties has nothing new ick

jeez the actor got corrupted, everything inside of it was in shambles. deleted and placed it again in the world fixed it. scary. This is what one of my structures looked like after the corruption

Quite funy actually, I am trying to reproduce it, because while my velocity on the x axis was not being maintained, it did stop my character from acting like a bumper car when hitting the corner of a ledge…Must, break, engine…

Ok solved. For anyone trying to figure this, I got a pretty solid work around that is easy to achieve. First of all, as mentioned above, the option Use Flat Base for Floor Checks effectively prevents the Character from “sliding” off a ledge.
Now for the “bouncing” away problem(Solution inspired by corruption above lol); all I did was update my X velocity (assuming you are using the X axis in your 2D game and not the Y axis) to 0 when hitting a wall or floor with my Capsule Component. This is what the graph looks like. Note that you don’t necessarily need to set it up with the “floor” and “wall” tags like I did, but for my project it works well.
Cheers!

My bad, you need to make sure that your movement mode is falling while doing this other wise it won’t work well when you fall on a flat surface where you would want to maintain your velocity. To do this, simply add a ==Falling with an “And” node to the branch.

Question, where do the wall and floor tags come from? I have this issue in 3d with static meshes

Thank you so much. This helped out a TON. I was a bit frustrated with this problem.

I even have an extended solution that works very well for me.
First, proper CharacterMovement settings seem very important. My character has a base size of 11x21 pixels. Its shape makes it a bit difficult to determine where to hit a ledge/fall off. Like recommended by OP, use “Use Flat Base for Floor Checks” for walking off ledges (extend walking options). The Perch settings are really important and definetly need to be fine tweaked. I used 2D boxes and build stairs that go steeper and steeper.

Regarding component tags: For testing purposes you can just drag a sprite in the scene and add a Component Tag in the Details tab. If you have many objects in the level you can mass select them and apply it everywhere. But it’s probably better to add the Component Tag later in your Blueprint (or per script?). When you add a PaperSprite component you can go into its Details tab and add the Component Tag there.

78022-walking.png

I’m using very small values for “Perch Radius Threshold” and “Ledge Check Threshold”. It will determine when your character starts wobbling its way through the edge of the ledge (since the capsule is rounded). If you use a too big value for “Max Step Height” your character will twitch downwards at times.

I then used Mortusnyte method of checking if falling to stop the velocity of the CapsuleComponent, so that you don’t slide off the side of a ledge that you hit when falling on it.

The problem now is that when jumping at an edge from below or on the side of an object you still might get pushed away and bounce off. I added a Box Collision in the base of my character to the Character BP and used its collision to do the same check that Mortusnyte used. But like this the character will already have its velocity reduced before the CapsuleComponent can touch the edge of the object.

I also was able to leave the Falling check out without noticable impact. Keep in mind that it will just work on objects that have the checked Component Tag. I actually just used one tag for my test.

This Box Collision will also change that when you jump at an object (with the Component Tag) from below the character won’t slide along anymore, but stop as if it hit its head (well, it does). If you have a high “Air Control” setting it will just be a small bump and your character continues moving. I like this more.

There is still a problem that if you jump pixel perfect on a ledge you might slide down. I added a video where you can see it at 0:41.

As you can see, works very well.

I want to elaborate on this since I’ve changed my code now to allow the player to slide over the ceiling. Since I got feedback on that I wanted to find a way to implement the ceiling sliding again. With the old solution the character would stop at the ceiling. This was actually not as nice in the long run.

Going ahead I removed the checks with the Box Collision since it works with just the Capsule Component.

Upon OnComponentHit I’m calling the macro

79253-answer1.png

In this macro I’m checking the component tag (tag floors as wall or add a floor tag or do it another way) and if the actor is in the Falling state. Then I run a Trace if the ceiling is above the character.

If it is, then do nothing regarding movement. But start a timeout and call a retriggerable delay to remove it soon again.

If it is not, then see if the timeout is active. If the timeout is not active, then stop the actors X movement. This is very likely somebody that hit an edge of an object. But if the timeout is active (this means that somebody jumped at the ceiling, but hit the edge of it and is sliding outside of the range of the trace check. Without the timeout the character would get stuck at the ceiling edge) then store the current X velocity in a float, divide it by 1.6 (felt like a good number regarding my character) and set that new value as the X velocity.

Hope it helps somebody.

I’m using a system very similar to this, but it still does not solve the issue of sliding off an object as you try to jump onto it. If the paper character attempts to jump onto a ledge but is barely able to get onto the corner, they will slowly slide down. The exception being if they release the movement key, then the character will ‘pop’ up onto the object thanks “use flat base for floor check.”

Currently I have a bunch of terrible workarounds in testing, including adding Z velocity to help pop them up, increasing their location in Z, and creating wonky collision volumes for platforms. The best solution so far seems to be hacking up the platform collision, where I make the corners into hooks facing upward, so the character can slip into the hook, then settle flat on the platform.

This needs a real solution from Epic however, as a side scroller game can’t be released acting like this :confused:

Can’t have box collision for that, as all other collision bounds are ignored by characters (they can’t be swept for whatever reason).

It’s too bad Epic dropped the ball on this, now many of us have to create a custom Pawn just to accommodate this. We miss out on a lot of the incredibly useful built in movement features, just because we need a box instead of an oval.

I’ve googled this extensively for the past few months, and the closest to an answer I have found is this thread. Anytime an Epic employee comments they say it is on the docket (which it is, backlogged from over a year ago on Trello). I fear that after wasting weeks getting my pawn working they will finally add this feature, so I keep putting it off.

edit: If anyone from Epic sees this, please consider adding box collision in some way to a beta build with a huge BETA warning attached. For many of us we can deal with a reduced feature set (I’m assuming step-up and many other movement features will break with box) just to have box available. Whether it is a separate character, or the ability to replace the inherited oval collision volume.

I’m having the same problem with sliding on those edges. The easiest fix for that would really just be to have box collision for the character movement. Little hooks wouldn’t be possible for me since the character can slide down walls and more. I’m currently focussing on other aspects of my game instead of trying workarounds. My game is multiplayer and another engine bug I hope will be fixed soon is the client character movement stuttering in the server window…

It’s been awhile, just curious if you had any ingenious ideas since. I’ve given up on this project for the past few months due to this, but since tried getting back into it.

I’d rather not have to create my own pawn with custom gravity just to get around this, but it’s the action I’m currently taking.

Hey. I kinda paused with this project and did smaller stuff down to taking a big break and am currently coming back to all this stuff, not particularly this project tho. I did a lot of progress in general after this thread. Here is the current version of that game I started: https://drive.google.com/open?id=0B5axpYpduzkkOHNHX3FnVjZWNXM I would say download it, check if the movement is fitting to what you’re looking for. If so I’ll check out what I did or upload the source (tho I’d rather not, since this is still my baby ;P) . Controls are WASD, Q, E, Spacebar, X. Or just try a controller. Don’t quite remember.

I love the edge grab mechanic! Just saying. Also these sprites are adorable, just saying (again).

Anyway, would you be alright with posting your blueprints for the edge-slide-prevention, so I can figure out where it has gone since the last version posted?

Don’t need the source! It’s your baby and tbh I would feel uncomfortable going through it. If you were alright with images, or maybe even the uasset files in particular to the edge-slide… well I would just greatly appreciate it.

Hey, thanks! :slight_smile:
Here is a link to the uasset of the character blueprint, I hope that helps! If something is missing just reply here again. Google Drive: Sign-in

Did you end up getting what you needed to work? I had made some pretty good progress with the whole 2d thing but dropped the project a while back.

OMG, THANK YOU SO MUCH Saiodin!
I have been trying to find a way to fix this forever!
All I was missing was right here all along I am so happy. Making a game right now and I was so annoyed with the bounces of edges!