I coded a custom input system that allows me to use axis triggers (for Generic controllers) as buttons. It is activated by checking for a public boolean in my gamepad script. This is what I have so far:
private bool tap;
public bool _GetTapped(int buttonIndex){
int i = buttonIndex;
if(Buttons[i].axisEnabled){
if(Input.GetAxisRaw(Buttons[i].AxisName) == 0 && tap){
tap = false; //disable the "tap" bool if the axis is no longer held down
}
if(Mathf.Abs(Input.GetAxisRaw(Buttons[i].AxisName)) * invertAxis > 0){
if(tap){
return false; //So it doesn't continuosly return true
}
else{
tap = true;
return true;
}
}
return false;
}
//If the button isn't axis controlled, simply use the joystick button keycode
return Input.GetKeyDown(buttonKeycodes[i]);
}
This allows me to press the axis button and it only returns true once. However, if I check for two different axis-based “buttons” in one update function, only the first “button” is recognized.
if(gamepad._GetTapped(7) && onGround){
anim.Play("light attack u");
}
if(gamepad._GetTapped(8) && onGround){
anim.Play("heavy attack u");
}
This is because of the tap boolean (I believe). I’m just not sure where to properly place it. My goal is to make each check for an axis “button” individual instead of only one “button” being recognized.
Is there any way around this? (perhaps using unique ID’s for each button press?)