I have a gesture recognition software. I want to perform a click by calling Input.GetButtonDown(“Fire1”) when user waves his hand. Right now I have:
void Update(){
if(waving code){
Debug.Log("user waved");
Input.GetButtonDown("Fire1");
} }
The “user waved” log shows just fine but the click is not performed. What im trying to do is essentially replace a cursor. User can move the mouse and once he waves his hand, whichever button is underneath will be clicked, so I cant tie waving to a determined button either. If anybody can help me with that or suggest an alternative, I would appreciate it.
You can try to make your own Input Manager.
You must be checking for “Input.Get…” to get true somewhere else in your code. Declare a static bool, and use that as input.
For example, lets say your character shoots whenever he waves hands, using a function called Shoot. So it could be like
public static bool fire;
void Update() {
if (waving code){
Debug.Log("user waved");
fire = true;
} else fire = false;
if (fire) {
Shoot();
}
}
By declaring it static you can use it in other scripts too.
Edit: Just saw you using GetButtonDown. For that, as soon as Shoot() is called, just set fire to false again. You can have another bool to keep track if function has been called, then don’t set fire as true till wave stops or something like that.