I wanna have Input.GetAxis to act like regular button (e.g. Input.GetButtonUp ).
As I’m using the GetAxis, everytime I shift the stick to one direction, the command inside the function is executed more than once, only need it to be executed once. Here’s my code. Anyway I can remedy this?
if ( Input.GetAxis("RightStickX") == 1 )
{
SwitchTarget();
}
I’ve found a way moments later after I posted this, here’s what I did to resolve my own problem. GetAxisRaw returns only 0 or 1/-1, it just doesn’t have the GetButtonUp function, so had to be resolved with a condition check, in this case using boolean axisInUse. Thanks for taking the time to help, appreciate it.
int state;
int cooldown;
if (state == 0) {
var inp_vert = Input.GetAxis (“Vertical”);
if (inp_vert != 0) {
cooldown = 60;
state = 1;
}
}
if (state == 1) {
//Do what you need to do
state = 3;
}
if (state == 2) {
cooldown--;
if (cooldown < 1)
state = 0;
}