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 :P .
asked Apr 10 '14 at 05:41 PM in Blueprint Scripting
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.
answered Apr 11 '14 at 12:09 AM
Marc Audy STAFF
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.
answered Sep 27 '15 at 02:43 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here