Search Unity

Remapping of keyboard keys on the fly?

Discussion in 'Scripting' started by csciguy, Dec 21, 2006.

  1. csciguy

    csciguy

    Joined:
    Dec 13, 2006
    Posts:
    22
    I've done a few searches, but can't find a definite answer on this. Maybe someone here can help me.

    I have a series of keys that are defined in a game, such as Forward, Backward, Left, Right, etc. These are mapped to W,A,S,D by default. I am looking to allow a user to map any key on the keyboard to these actions through a menu system. Basically I want to remap the keyboard in game, via a menu system instead of when the game starts (before it actually launches). Is this possible?

    Example:

    Everytime I press W, the user moves forward. The user brings up options and wants to map Forward to 'R'. How would I do this with some sort of Input function (Input.GetButton ???) when I don't know the button name of the key the user has pressed?

    I have the facility for a user to input a key (it's through a menu) but I don't know what Input function to use to capture this keystroke.

    Thanks.
     
  2. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    The only way to do this (as of now) is to bypass the included button settings entirely. I do this in Botbuilder, but only because its controls are so nonstandard that attempting to fit them into the standard mold would be an exercise in futility. In general, it's not a good idea.
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Typically, using the built-in method for redefining controls when you launch the game should be enough anyway. (Although I think Windows builds still don't have this?)

    --Eric
     
  5. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    I believe redefining the controls is something quite essential to any good game. Or at least a great commodity.

    What I dont understand is why exposing the input settings would be an issue in the first place.
     
  6. freyr

    freyr

    Joined:
    Apr 7, 2005
    Posts:
    1,148
    There is no issue (as in a technical hurdle) as far as I know. The only issue is that it actually needs to be done by some of OTEE's developers. Features don't just show up by themselves. :)
     
  7. Der Dude

    Der Dude

    Joined:
    Aug 7, 2006
    Posts:
    213
    You should work on that! =)