How to DELAY A FUNCTION in Unity (INVOKE method)

preview_player
Показать описание
In this video we see how to call a function with delay. To do this we use the "Invoke" method defined in the MonoBehaviour class, this method requires two parameters, the first is a string data that contains the exact name of the method to be executed and the second parameter is a float value with the time in seconds that the function will be delayed, then with the following instruction for example:

Invoke("MyFunction",2f);

What we do is to execute the function called "MyFunction" after two seconds. This function has to be defined within the same script, otherwise the call will not be made.

____________________________________________________________
*LINKS*

____________________________________________________________
Рекомендации по теме
Комментарии
Автор

Beautifully explained, I had no idea Invoke existed. That saves me a lot of heartache. Gracias!

TheGrimmy
Автор

I would not have understood it half as well without the handgestures hahaha you are a legend, my friend! thank you!

rikm