- Home /
Store Variables in Variables?
Hello everyone i want to make a Keyconfig script but im stuck. Right now i have it setup that every Aktion like move forward, move left, move right etc. has its own function for configuring it like this
public void Configforward () {
if(Input.GetButtonDown("Q")){
forward = "Q";
Configstufe = 0;
}
if(Input.GetButtonDown("W")){
forward = "W";
Configstufe = 0;
}
if(Input.GetButtonDown("E")){
forward = "E";
Configstufe = 0;
}
And so on for every key on the keyboard
}
But this gets me a like 2000letters long script. so how can i store the forward in another variable so i can say in my other script set varibale aktion to forward and then it sets forward to the key. I think its possible with a arraylist but i dont have much knowlege white arraylists. Can someone please help me? And sorry for my bad english.
Answer by Muuskii · Sep 24, 2012 at 08:35 PM
You mean something like Input Manager? Note: that package does everything you're making and is being updated all the time. (Even as type this)
Answer by JonyderKiller · Sep 25, 2012 at 12:01 PM
Hm i am not sure but i think its something like that. But the thing is i want to write it on my own to get the best understanding and also i dont want to pay money for scripts its a bit stupied i think.
And do you know if its possible with arraylists, because i think it is i just dont know how.
Your answer
![](https://koobas.hobune.stream/wayback/20220613081436im_/https://answers.unity.com/themes/thub/images/avi.jpg)