Assigning axes input (Fire1/Jump) value to a variable,Assigning axes input value to a variable

I need to be able to change an input value, such as Fire1, Jump, Horizontal etc to equal a variable I will define. I realise this is a strange thing to do, but is it possible? ,

if you are looking for a way to have players assign their own button inputs for customized play, then I think you could use this…

here’s the code— You need a string variable Called CONFIGBUTTONS2 for this instance to work.

var Numbers1 = new Array (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
for (var go1 : float in Numbers1) {
if(Input.GetKeyDown("joystick 1 button "+go1)){CONFIGBUTTONS2 = "joystick 1 button "+go1;}
if(Input.GetKeyDown("joystick 2 button "+go1)){CONFIGBUTTONS2 = "joystick 2 button "+go1;}
if(Input.GetKeyDown("joystick 3 button "+go1)){CONFIGBUTTONS2 = "joystick 3 button "+go1;}
if(Input.GetKeyDown("joystick 4 button "+go1)){CONFIGBUTTONS2 = "joystick 4 button "+go1;}
if(Input.GetKeyDown("joystick 5 button "+go1)){CONFIGBUTTONS2 = "joystick 5 button "+go1;}
if(Input.GetKeyDown("joystick 6 button "+go1)){CONFIGBUTTONS2 = "joystick 6 button "+go1;}
if(Input.GetKeyDown("joystick 7 button "+go1)){CONFIGBUTTONS2 = "joystick 7 button "+go1;}
if(Input.GetKeyDown("joystick 8 button "+go1)){CONFIGBUTTONS2 = "joystick 8 button "+go1;}
}
var Numbers2 = new Array ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z");
for (var go2 : String in Numbers2) {
if(Input.GetKeyDown(go2)){CONFIGBUTTONS2 = go2;}
}

So this script checks through all the buttons on 8 separate joysticks and returns it in the form of the String CONFIGBUTTONS2. So if you want to assign that to an input button, just assign the value of CONFIGBUTTONS2 to another variable like ABUTTON. then use that ABUTTON in…

if(Input.GetKey(ABUTTON)){
//do something
}

I have yet to find a way to easily find all the Input Axis’s, but those aren’t nearly as complicated as the 150+ joystick buttons. Hope this Helps!

A better understanding of what exactly you’re trying to do would help here, but one way to modify an input value is to cache it temporarily like so:

		void Update ()
		{
			// Cache input value.
			float inputValue = Input.GetAxis ("Horizontal");

			// Modify input value if overiding value exist.
			if (inputValueOveride != 0)
				inputValue = inputValueOveride;

			// Then do something with input value.
			transform.Translate (transform.forward * inputValue * Time.deltaTime);
		}

Or you could have a boolean value to check where the input value should come from:

		void Update ()
		{
			float inputValue = 0;

			// Do we accept player input?
			if (playerInput)
			{
				inputValue = Input.GetAxis ("Horizontal");
			}
			else
			{
				inputValue = 0;  // Whatever value you want.
			}

			// Then do something with the value.
			transform.Translate (transform.forward * inputValue * Time.deltaTime);
		}