How can I change the input key mapping at run time via scripts .

Hello

We are doing few different camera control mode in our application, because we are using a joystick to simplify the control for the users. but we find that to make the all different mode work nicely with the joystick, we need to change the key mappings in unity editor/input manager.

So the Question is, How can I change the input key mapping at run time via scripts?

Thanks

Rather than changing the inputs, you could use Input.GetKey() and then you can simply insert a string with the key name of the key that you changed procedurally. If you are using a joystick for the axis, then the rest are buttons, this should work fairly well.

example:

var curFireInput : String;

var normalFireInput = "a";
var specialFireInput = "b";

var controlStyle = "normal";

function Start () {
     switch (controlStyle)
      {
      case "normal":
           curFireInput = normalFireInput;
           break;
      case "special":
           curFireInput = specialFireInput;
           break;
     }
}

function Update () {
     if(Input.GetKey(curFireInput)) {
         //Run code here;
     }
}

There is more than likely a better way of changing the value than a switch statement, but this is just to show how you might change the variable for different inputs.

Edit: Or, similarly you could create multiple inputs in the input manager and switch those out depending on the control scheme. It would make it easier to do axis inputs.

This feature has already been requested, and it would be very useful!! Vote for it here: http://feedback.unity3d.com/forums/15792-unity/suggestions/175032-scripting-expose-input-manager-settings