I may be bad at finding actions I need. This one must exist already, and if not, now it does.
GetAxisToButtonDown.csTake the axis you provide, and treat the directions as buttons ("Negative Button" and "Positive Button", and also the alternatives as listed in Input Manager). To do this right now, you would get the axis, store it into a variable, and then feed it into a float compare. This makes it in one go.
Explanation for BeginnersIt's recommended to use the Input Manager (Edit > Project Settings > Input) to map the player input from mouse, controller, keyboards etcetera.
Use CaseSuppose you want
up for jumping, and
down for crouching, hence you want to treat the input axis direction as if they were buttons (e.g. as they were in old gamepads).
Note Uses the snappier GetAxisRaw function, which means, there is no ramp up (also see my
GetAxisRaw action). That's a bit of taste, or Game Feel. You can change this by simply replacing "GetAxisRaw" with "GetAxis" in the code. It can also store whether the buttons were pressed, but I have out-commented that functionality, as I don't really see a purpose. If you want to add it back in, just open the code and uncomment it (it's easy for beginners, too). I also have a more advanced similar action I need to revise (on request, otherwise when I get to it), that has settings for stick deadzone and threshold.