Giving Movement Input Priority

I am making a game where the player can move freely on a grid. When the player is using a keyboard I would like for the game to prioritize whatever axis was pressed first, so if the player is moving along the x-axis, the game will ignore any input from the y-axis until the x-axis is released. So the player should be able to move forward, then hold down the move right button in preparation for a turn, then release the forward button to complete the turn.

This is how I’m managing it at the moment, but this method gives priority to certain directions, when it shouldn’t.

Hey @sweeetjd!

This isn’t really enough code to be able to understand much of what’s going on- and I’m really not sure what you’re getting at with “priority” to certain directions. But what I do see is that your < node is checking is going to return false if there is an input for X AND Y, no input for X and Y, or ONLY an input for Y. It will return true ONLY if an X-Axis value is given by itself. That’s unfortunately really all that can be gleaned from this snippet here.

If you would like more in-depth analysis, please provide us with more code, and we’ll see if we can’t get to the bottom of this! :slight_smile:

Thanks for the quick reply!

Here is the full blueprint:
Movement posted by anonymous | blueprintUE | PasteBin For Unreal Engine

It actually works quite well for the most part. Let me try to explain a little differently. In this controller, you can move in any cardinal direction using the arrow keys. Sometimes the player will need to be able to make quick changes in direction to avoid enemies. Its a little nit-picky, but I believe that the controller gives priority to the Y-Axis.

What this means is that if you are moving along the x-axis and press the right arrow key, you will move right instead of forward. However, if you are moving along the Y-axis and press Left, you will not change directions. So basically, I just want to make it so that whatever axis you are moving along, you will continue to move along that axis even if you start pushing another direction. Then you should be allowed to change direction if you release the key that is moving you along the first axis you were moving along.

I mean this code here is 100% GIVING priority to Y-Axis inputs- as it is only going to branch TRUE if you are NOT pressing any Y-axis inputs, given that the inputs are digital and absolute.
image
X=1, Y=1 == F
X=0, Y=1 == F
X=0, Y=0 == F
X=1, Y=0 == T

So essentially, without looking TOO hard at the entire system, I can see here that you’re having an issue with, as you stated, Y-axis getting prioritized- and here this is hard coded to do so. This should be the focus first, as the inputs are controller based, not world-based, right?

1 Like

Okay, that’s good to know. The game is presented in isometric view that can be rotated, so the view is world based.

id say use 2 different inputs and switch which one is active with a bool or enum

2 Likes

That did the trick, thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.