Specific Character Movement issue - 2D sidescroller

Hello,

This is my first day developing in Unreal 4, and I’m going to come right out and say it - I’m an artist trying to do some blueprint gameplay! :slight_smile:
I’ve fumbled through to almost achieving what I set out to do, but have a small bug I would love to iron out in the way my character is moving for a 2D side-scroller. Hopefully this thread will help others too!

Basically I want my little character to move to the right (-Y direction) automatically without any input, then if he hits a wall he’ll turn around and walk back (+Y) until hitting a wall and being reversed again. So no controller inputs, a bit like lemmings might move!

It works apart from when falling, which seems to return higher values than hitting a wall (and always turns him). So he walks off a ledge and then returns in the direction he came from, rather than continuing forward, which is what I want to fix!

Here are the nodes I laid out, mostly through trial and error, so I’m sure someone can pick this apart and teach me a better way:

f70cf1c8142b0f56daf79c0a2910a3746daa48ce.jpeg

My best guess is that the Dot product node is doing something I don’t want it to - I basically was trying to clamp out the X and Z channels of the Hit Normal Vector (to hopefully leave Y direction from -1.0 to 1.0), but couldn’t find a node to mask them.

Any help is much appreciated, once this is cracked I can get back to making things pretty which I’m much more competent at!

Thanks,
J

You want something like:

Direction is a float - you can set the initial direction by setting this.

Note:the side scroller changed slightly recently - you will of course want to set the world direction as 0,1,0 in the **AddMovementInput **node if you have the older version.

Hi Bruce,

Thanks very much for the reply on this. I’ll play around with this once I’m home from work tonight, I can already tell you’re using a few handy nodes that I didn’t know about.

Appreciate your help!
Thanks.