- Home /
Redefining input within game
How can I change what input is associated with what action when playing a game in unity as opposed to using the unity interface to mapping input? Either as an ingame main menu - redefine keys option, or by pressing a specific key to alter key-mappings during the game.
Answer by Extrakun · Mar 14, 2010 at 09:44 AM
Instead of using Unity3D's predefined input constants, create a Hashtable which holds associated action string (or number) as the key, and the actual keyboard code associated with the key.
You can create new or change existing mappings by modifying the hashtable.
(Warning :untested code!)
public static var key_lookups : Hashtable = new Hashtable;
function Start() {
key_lookups["down"] = KeyCode.S;
}
function Update() {
if (Input.KeyDown(key_lookups["down"])) // go down...
}
Your answer
Follow this Question
Related Questions
InputManager, Gamepads, Wheels: remapping and calibrating 1 Answer
How to map input for new Samsung Gear VR controller? 3 Answers
How to map multiple different types of controllers at the same time 2 Answers
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
Key Mapping 1 Answer