Hi guys! C# noob here, but doing my very best with what I know so far.
I need to have a collider activating only when it is held down for 0.5 seconds. Is it possible for it to be done via a Pointer Down Event Trigger? Also, I’m trying to use the Event Trigger mainly because I have a lot of collider buttons that in the game and I would like to use this to easily allocate functions.
To provide some context, I have a separate script where an UI image will appear and do a radial fill (to look like its searching/loading) and when the button is held for the allocated time(0.5s) the desired action would happen(“You found an item in the bush!”). And if you release the button early nothing will happen.
Essentially similar to the Gwent single player game, Thronebreaker’s looting mechanic.
Here’s what I tried to do but it doesn’t seem to be working
The idea is to have a coroutine checking on conditions when the button is held down. And stops checking if button is released. Any help is appreciated! thanks in advance!
public void OnButtonClick1()
{
StartCoroutine(Checker1());
}
IEnumerator Checker1()
{
while(true)
{
if(Fillamt > 0.8f)
{
//"You found an item in the bush!"
break;
}
if (Input.GetMouseButtonUp(0))
{
break;
}
else
{
yield return null;
}
}
}