Hello,
Been playing in Unity for about a week now. So far I was able to find all the answers all around the internet, but for this problem I’m clueless (mainly, because I don’t know how to properly formulate the question…).
In this game if you click the character fox it sets a parameter to certain value, then it should wait for 2 seconds and revert the parameter.
void FixedUpdate(){
....
if (hit.transform.name == "fox")
AudioRecorder.noiseMin = 20;
else
StartCoroutine(ReturnNoiseMin());
IEnumerator ReturnNoiseMin()
{
yield return new WaitForSeconds(2f);
AudioRecorder.noiseMin = 0.5f;
}
...
}
Works fine when you click the character only 1.
However when you keep clicking, the first 2 seconds pass and for a few frames it sets the value back.
Which is kind of logical and expected, but I can’t figure out how to “prolong” this 2 seconds with each click.
I tried using Time.time + 2 seconds, but its the same thing just written differently…
I believe the answer is simple and stupid, but I just can’t figure it out and this is my second game with the same issue. In the first it was on collision => slow down object => after 0.5 seconds return speed, but if you kept colliding every 0.5 seconds you got the speed back for few frames…
Thank you very much for any hint.
Best Regards
Petr