I am wonder if it is possible to change the input keys used from their default WADS setting to new custom keys through code rather then using the input manager. If so how can I accomplish this?
asked Dec 10 '10 at 04:55 PM
No. I do not believe that you can change the virtual buttons defined in the Input Manager through code. You would have to either change them in the Input Manager in the editor, provide the Configuration Dialog or define your own setups using the specific keys, etc.
One way to do your own setup for configurable buttons or axes is to define an Enum or array of key identifiers which somehow(your choice) map to the key names used by GetKey and then store the key string in a variable whenever you set it and when checking input, use Input.GetKey(keyString). Wherever in code that you need to change the key, you merely change this string variable and it just works. This is essentially a virtual button and you can setup all sorts of other settings for damping and sensitivity and whatever to emulate GetButton or GetAxis as you need, with the exception of Input Axes not defined by keys, which would have to be retrieved by button name.
Another option is to have several different buttons/axes defined in the Input Manager with different names. By controlling the value of a button/axis string in much the same way as above, you can change which Button or Axis that you want to use by simply changing the value of the string, Input.GetButton(buttonString); Input.GetAxis(axisString); and such.
answered Dec 10 '10 at 05:12 PM