- Home /
Dynamically Assign Axes to a float value.
I'm working on assigning controller input to something in my game, and I'd like to add a feature where I can map controller axes/sticks to a float value (eg. stickX).
Currently, my code looks like this.
stickX = Input.GetAxis("Axis 1");
stickY = -1 * Input.GetAxis("Axis 2");
This is very much "hard-coded", and doesn't really work for controller mapping.
My thought process is that if I can get either lower-level access to raw input, that I would be able to do this, so is that a path I can pursue?
Alternatively, is it possible to solve this another way? Controller input is extremely inconsistent, as sometimes sticks show up as buttons, and buttons show up as sticks, and so hard coding obviously doesn't work. I know that using the input configuration on startup is an option, but it's certainly much less seamless than having an in-game, press buttons to map them configuration option, as many games have.
If you've encountered something similar, need more, or have something that could point me in the right direction, I'd really appreciate it.
Thanks!