How Can i make my character run forever like in games like super meat boy or Super leap day on ios

I’m really struggling to find out how I can make my Character run in a straight line, my game is 2D so I need the Character to run along the Y axis, and turn around when hitting a wall, i added a detection box, some basic turn character logic and some movement, but every time my character hits a wall it starts perpetually flipping back and forth no longer moving, I’ve tried endlessly to bug fix even going as far as to restart the whole project but i cant find any support. If its important I am using unreal 5.3 as well as Paper2D/ZD. attached are screenshots for how the movement is set up. Here is a link to the super leap day trailer, it gives a very clear example of the movement I’m looking for. also I know typing can be a hassle so if there’s tutorials or other documentation out there for this that i just couldn’t find I’m more than happy being redirected there, thanks for everyone’s help. Cheers!



Hey @Aries_42069420!

So what’s happening is I believe it’s triggering the Turn Char function too many times. Try putting in a “DoOnce” node before that to test it.

If that does work, you can leave that DoOnce, put a delay after “Turn Char” for .5, and pass that into the reset on the DoOnce! :slight_smile:
Let us know if it works!

So i added the do once node, it stopped the jitter but now the player wont continue in the other direction, i did a little bit of a deeper look at the collisions without the do once node and while simulating my character, the “On Component Begin Overlap (WallDetector)” just keeps going off, kinda like a loop. im not too sure what could be colliding because my ai pretty much uses this exact code and it works just fine, both are Paper Character Blueprints. my thoughts were either that was the problem or its because my character can only move forward so it keeps flipping, hitting the wall, and flipping again. either way idk how to fix either lol, ill see if i can post a yt vid that actually shows what the character is doing and the collision boxes if you need. thank you for the help!

here is a link to a video displaying the problem with and without the do once nodes

Okay, let’s leave the Do Once and the Delay (with reset) and on tick, get actor rotation on self, and hook that up to the print string.

We want to make sure that it is rotating correctly, because it SEEMS like it isn’t.

Another thing you could do is have a “Is Moving Right?” bool, and set that as NOT “Is Moving Right?” every time it collides.

So it would start T(right), hit a wall, make it F(Left), hit a wall make it T(right) again, and so on.

Then on tick, use a branch to check “IsMovingRight?” and on T go as normal but on FALSE, multiply Actor Forward Vector by -1.

Now that I say that, I realize you could probably just replace the +180 on collision with rotator*-1.

would you be able to post a screenshot showing what you mean? i dont think i understand

Let’s take it a step at a time because a lot of this won’t work right without knowing the pawn’s rotation- we need to make sure it’s 0,0,0 or 0,0,180.


Set this up, and you’ll constantly know the character’s rotation- if it’s not flipping from 0 to 180 that’s where the problem lies.