I'm currently making a purposefully frustrated mini-game where the movement keys change each time you use them. I intended to do this with the code bellow.
public class Flop : MonoBehaviour
{
private string[] DirF = new string[] { "r","f","v","t","g","b","y","h","u"};
private string keyF = "y";
void Update()
{
if (Input.GetKeyDown(KeyCode.keyF))
{
// insert code to do a little flop and select a new index to represent keyF
}
}
}
this is simplified from what I wrote, but essentially using the keyF variable to quickly replace the necessary input in the jump command. Initially I tried to make it a string as shown above, but clearly the KeyCode command doesn't accept strings and I have no idea what variable could be inserted instead.