How to make an event every second (Unity)?

  • 0
    How to make an event every second, please help!
    Unity Game Engine Jacob Hutchinson, Jan 1, 2019

  • 3 Answers
  • 0
    Use coroutines and WaitForSecondsRealtime

    public class FooComponent : MonoBehaviour
    {
    private void Awake()
    {
    StartCoroutine(YieldOneSecond());
    }

    IEnumerator YieldOneSecond()
    {
    while (Application.isPlaying)
    {
    yield return new WaitForSecondsRealtime(1f);
    }
    }
    }
    Adeline McCall

  • 0
    Create a timer?
    Evangeline Melton

  • 0
    Each Update check if a second has passed since the last second.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!