I tried to rewrite the code not to have the function with a parameter and then call it easily in Update, but this destroys all my code. It seems the only solution is to have input outside the function. After a few tests, the only solution that works for me is: