x


Change WADS to custom Keys through script

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?

more ▼

asked Dec 10 '10 at 04:55 PM

mimatos gravatar image

mimatos
129 12 13 15

Make your own inputs... In Unity:

  1. Edit
  2. Project Settings
  3. Input
  4. Check out Unity has it, but make it for your own (Name your axis and what not).

Should help out.

Dec 10 '10 at 05:05 PM Justin Warner

@Justin Warner: That's still done through the Input Manager and does not help because that's what the op is trying to avoid.

Dec 10 '10 at 05:18 PM skovacs1
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Dec 10 '10 at 05:12 PM

skovacs1 gravatar image

skovacs1
10k 11 25 91

True, I was hoping this was possible but the more I think about it and review it I don't think it actually is. Thanks for your answer

Dec 10 '10 at 05:22 PM mimatos
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x379
x61
x43

asked: Dec 10 '10 at 04:55 PM

Seen: 1712 times

Last Updated: Dec 10 '10 at 04:55 PM