Download

problem with player movement only in X/Y straight lines

Call me stupid but it took me a while to rid of the default ‘blank project’ controls and create my own gamemode.
With it I managed to create my own control scheme , based on the sidescroller example but to move in 2directions.

It uses Up/Down/Left/Right buttons to move in X and Y positions.
Which works fine when pressing the directions individually, but when pressing multiple (eg UP & RIGHT) my character move diagonally, which I don’t want it to.
This is my current blueprint, which is pretty straightforward, but I can’t figure out how to block the movement to 1 direction at a time
74fafdde4eb19ecf263bbbd15a0b30e8a599ee85.jpeg

I do hope someone can point me in the right direction (no pun intended).

How about a float comparison node after each input event node that compares the other’s float value. Then you could have whichever direction take over depending on which was pressed first/last by perhaps setting the float of the direction you don’t want to zero.

Or you could make the world direction vector a variable, and have the events set the variable themselves.

Unless I misunderstood your suggestion, I tried something similar, but that did the same as what I currently have.
So far Ive experimentd with variables and a collection of branch constructions, but it seems the inputAxis functions are constantty triggered (I tried PrintString,which was constantly outputting) resetting or blocking whatever variable I just set.

I feel like if you have one event set a world direction variable to 1,0,0 and the other sets the same variable to 0,1,0, they wouldn’t combine values. I’m not at home so I can’t mess with this. Did you promote the world direction value to a variable? If so, you would only need one add movement input node, with world direction connected to your variable.

Thanks for the suggestion, you are correct I am setting 100 and 010 as I wouldn;t understand how else it would know what direction to move in.
I finally had the time to try this butalthough I’m sure I’m doing something wrong myself, I can’t get your suggestion to work.
Should I take the world-direction and add change it somehow depending on button pressed? currently they only share the same world-direction 3vector variable.

Make it so that when you press a movement key, it disables all other movement keys until released.