Button or Input Filtering?

Right now I have a top down character who moves using the W, A, S, and D keys by using AddMovementInput . However this allows the character to move in diagonal directions if multiple keys are pressed. Does anyone know of a way to constrain movement strictly to one axis at a time?

I would also love to hear of additional ways of moving my character besides AddMovementInput if anyone happens to know a good one :stuck_out_tongue: .

I believe AddMovementInput is safer than changing movement manually. Unless youre Actor is not a Character but a ship or object of some sort. Here is what I came up with question.

If I figure out another way to do it, I’ll make another post. I tried few ways and this seems to work best. On the left the keys WASD assign themselves, and on the AddMovement where it applies the Axis Value. You detour the axis when its the opposite axis. Only kink I noticed is when you hit a button on the same Axis such as W & S. When you’re holding W, and you hit S you stop moving. Otherwise, it constrains to one direction at a time.

Instead of using the InputAxis Events you could try using the InputAxis Values and then driving movement from your Actor’s tick event. Then you can examine the value of both axes and make a decision on whether you want to update the movement or not.

There decision is still required. Meaning to determine if this is the Axis they want to be on. Also, you would have to assign Axis. Example, if you have them going forward. You would assign the Axis as Forward & Back, but if you go back, then release. It resets the permission. So then this requires individually adding permission. There must be an alternative because the solution I provided still feels like too much to me.

So if anyone wants to provide an answer, I would love to see it.

Check the absolute value of both input axis against each other.

If forward input is bigger than right input, use the value of forward input and set the right input to zero. Vice versa for the right input.