- Home /
The question is answered, right answer was accepted
Possible to remap input manager buttons/axes at runtime?
Hello,
Thanks for reading. The basic question is: Is it possible to change to change what keys are mapped to a particular axis/button in the input manager at runtime? I've attached a screenshot of the controls I'm trying to remap. One is an axis, called vertical. The other is a button called fire.
I've also included an example of the code for checking if a button/axis is being pressed for movement or shooting in-game. I haven't added controller support yet, but I'd like a solution that won't prevent it from being added later. Thanks
if(Input.GetButtonDown("Fire1"))
{
// Do something
}
InputMovement = new Vector3(Input.GetAxis("Horizontal"), 0 ,Input.GetAxis("Vertical"));
EDIT 1: Looks like this feature may not be available. Has it been added? http://answers.unity3d.com/questions/184700/how-to-access-input-manager-via-scripting.html
There are lots of input managers on the asset store. There used to be only a few, so I made one with the functionality they were missing. Now there's a lot more competition. Pffthhgh. :)
Duplicate question....
Answer: No
Workaround: already stated
The closest thing to what you want (besides third party) is the users ability to change the inputs when they launch the game.
If people can write their own input managers, that gets around the problem. How does one write an input manager?
Please don't necro post something like that. Ask a general design question like that on Unity Forums.
Answer by dorpeleg · Jun 27, 2013 at 06:09 AM
This has been asked a lot.
It is currently not possible.
The only way to do it, is to create your own input manager.
$$anonymous$$nock knock.
4 years and counting?
This is definitely something that the Unity development $$anonymous$$m should address. Any movement or roadmap for this?
Unity projects have different configurations and not being able to mix the project settings or especially the input settings between two scenes from two different projects makes it more difficult to work with Unity.
Thanks. Omar
Hi Omar,
As others have said, the best solution is to use a 3rd party Input $$anonymous$$anager. There are quite a few on the Asset Store and some are free. If you'd like to create your own you can use this code to get you started however I have yet to find a way to map joystick axes in run-time.
$$anonymous$$eyCode thrust = $$anonymous$$eyCode.None;
void Assign$$anonymous$$ey()
{
if (thrust == $$anonymous$$eyCode.None)
{
foreach ($$anonymous$$eyCode kcode in Enum.GetValues(typeof($$anonymous$$eyCode)))
{
if (Input.Get$$anonymous$$eyDown(kcode))
{
thrust = kcode;
}
}
}
}
void Thrust()
{
if (Input.Get$$anonymous$$ey(thrust) == true)
{
myT.position += myT.forward * movementSpeed * Time.deltaTime;
}
}
Any movement or roadmap for this?
Yup. They first announced plans in 2016 and discussed the redesign setback in 2017 (and released builds too).
Current status: still under heavy development.