I am trying to achieve the simple step that the vignette increases while my player is crouching, and decreasing the value while he isn’t crouching.
Here is the code where I call the method:
And here is my code for changing the value:
This works only once. I am pressing my crouchKey and the vignette appears smoothly. I press the key again and the vignette disappears smoothly. Good!
But as soon as I press the key again to crouch, the vignette instantly changes to the other value, but if I press the key to stand up it disappears smoothly again.
I suspect it is because you have multiple ChangeVignetteValue running. Let’s walk through it.
First crouchkey. ChangeVignetteValue runs once. Enters crouching while loop.
Second crouchkey first ChangeVignetteValue exits and a new one starts, entering !crouching while loop!
Third crouchkey. Second ChangeVignetteValue exits !crouching while, but then enters crouching while. A third ChangeVignetteValue starts which also enters the crouching while. You now have two while loops running.
Now the second one sets it to full because it’s time.time - timeToStart returns a high enough value.