I was wondering, it is possible to bind positive and negative buttons as a command. Like with GetButtonDown. I have a script where if you hit left or right certain animations play, but how do I rebind it so that players can re-assign these keys?
What you can do is get the button and then check for the corresponding axis, like so:
if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") > 0) {
// Move to the right
}
else if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") < 0) {
// Move to the left
}
Also be aware that the axis is set to SNAP. This means a change of direction instantly sets the axis to 0.
The documentation linked above is saying you should use
value = Input.GetAxis ("Horizontal");
and then check whether the value is above or below zero.
In the doc for GetKeyDown there is mentioned to use GetButton instead,as it allows binding,while GetKeyDown works on enum:
http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html