Need help with Character Movement

This won’t work perfectly but it’s a start.

Open the character blueprint class

Under the components panel click the character movement component

Under the details panel search for orient rotation to movement and un-tick it

Also in the event graph of the character blueprint disconnect the mouse inputs so that the player won’t be able to move diagonally.

The problem is that for an ideal situation, you’ll want the Player to change directions if you add a new input. This means you need to track when the button’s are pressed.

The solution I’ve made below is probably ideal for you, because if you press Up then Right, then let go of Right while still holding Up, then you’ll resume going up until you let go of Up.

First, we need to change the inputs from being Axis values to being Events that you can use them to track when they happened.

Go to EditProject Settings and find the **Engine - Input ** section on the sidebar. Then setup your inputs like this.

Now create five DateTime variables. OffTime, ForwardTime, BackTime, RightTime, LeftTime.

Then setup your actions to record when they are pressed and released.

Now create a new function to get your desired direction. This is the brain of choosing which way to go based on what DateTime values are stored in your variables.

It chooses which value was pressed most recently, and passes on the desired direction vector and the winning time value.

Now last step, is simply inserting that function into your Tick Event where you were deciding where to move the Player

And you’re done!

Happy to help, glad it worked for you.

Hi There

I’m fairly new to the concept of Blueprints, I really hope you guys can help me. I’m using the Twinstick Shooter, I want the player only to control the actor in four directions, North, South, East and West. The way the blueprints are setup at the moment the actor can move in a complete 360 degree direction, I basically only want the actor to move 0, 90, 180 and 270 degree directions. So if the player presses left the character goes left, if the player presses up the character goes up and so forth something like the controls for pacman if that makes sense.

This is the way the blueprints are setup at the moment.

Thanks everyone!

Hi,

Go to player character BP and follow my graph,

Note that the directions are based on world direction so make sure that your camera always faces north. If you want to have directions based on your camera directions, then follow this [link][2].

Also in this setup, your character will face the 4 directions instantly. If you wish to have your character to turn toward these directions, you can use a timeline to make it happen. Another thing to note, is since you said you want to have only 4 movement directions (not corner directions), I have filtered all other directions.

Hope this helps.

Regards,

Thanks BenVlodgi, this is exactly what I wanted and the tutorial you set out was wonderfully easy to follow, Thank you so much for the help.

Thank you for your reply!

Thank you for your reply and setting out this example for me