You would use vectors
I would take my Input Axes and make them a vector (This vector will give you a direction and magnitude from 0,0,0 to X,Y, Z (you could probably use a 2d vector for your input, or use the Z-axis input as your “run” so player can control how hard they are running). The X and Y portion of the vector would tell your character how fast to walk in what direction.
I do not quite follow the behavior you are trying to describe with controlling running according to direction? Does the character rotate? If so, then are you trying to control the run direction according the World Coordinates? Is your character unable to turn, and can only move forward or Side-Side?
If your character does not turn, then you could check the Input Vector against the Character’s Forward Vector. If I am thinking correctly, you could use Dot Product of the vectors to determine if your Input Vector is beyond 180 degrees from your Forward Vector. You could go about this 2 ways, booleans or math. You could setup a branch to check the angle and set/unset your run boolean, or you could find a way to use math using the Dot Product by perhaps getting the Sign (Node) of the Dot Product, clamping to 0-1 and then multiply your run speed by the result, which should be 1 or 0.
Understanding vector math is super helpful in game programming. I highly recommend trying to masster an understanding of various vector operations such as dot product and cross product ect. Here are some links:
when you press the shift key the character starts running. But it must only run in the forward, left-front, forward-right directions. When the player presses the A, D, S keys the race is canceled and returns to walking even if the shift is held down
I managed to create this, when you press the “S” the character stops running. But I don’t know how to do it with A and D. Because I need that running with W, AW and DW
Sorry but I didn’t understand you, the camera is fixed behind the character, to rotate the character you have to move it with the mouse. Otherwise the character can die in the 4 directions without the ability to turn around.
I really don’t understand what you are trying to describe by saying the character can die in 4 directions? If you are rotating with mouse and moving character with keyboard, instead of using Actions, setup Input Axes using the keyboard keys. Take a look at how I setup my Axis Inputs for keyboard keys.
I cant take you much further than this because I dont understand the mechanics of your game well enough to figure out the other vector you need to get the Dot Product. But, once you have a second vector and can get a Dot Product you can do something like this:
The end resutl will be a 1 or a 0, you then multiply the end result by your increased walking speed (or multiply the end result by your Z-Input and then add to walking speed) and add that to your normal walking speed (if run button is pressed). So your walking speed is 250, and your run speed is 250, get the difference to determine the run speed to Add. So if your walking speed was 100, and your running speed was 300, you would take the difference, 200, to add to your walking speed to get the run speed.
Unless you give a lot better details of your game mechanic your trying to make, I cannot help any further.
You probably dont have to clamp the inputs as I did, that ended up being particular to my game setup (using keyboard and joystick inputs at same time ends up giving result higher than 1)
I’m curious as I see this solves the problem of the run speed dependant on the run input being pressed, but how does this solve the direction problem of the question? Or was that not an issue?