How to DELAY A FUNCTION in Unity (INVOKE method)

Опубликовано: 28 Октябрь 2024
на канале: GDT Solutions
4,296
65

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

Portfolio: https://gamedevtraum.com/en/portfolio...

LinkedIn:   / gamedevtraum  

Downloads: https://gamedevtraum.itch.io/

Contact 1: [email protected]

Contact 2:   / gamedevtraum  
____________________________________________________________