0 votes
by (8.2k points)

Is it possible to make the enemy follow my player after some time of spawning?

1 Answer

0 votes
by (8.2k points)
edited by

In order to execute a function after a delay in Unity, you can use Invoke().

If you want to invoke a function after a delay, then repeatedly call it, use InvokeRepeating().

Example:

  void Start()
  {
    Invoke("SayHello", 2.5f); // 

    InvokeRepeating("RepeatMe", 1.5f, 1.0f);
  }

  void SayHello(){
    Debug.Log("Hello!");
  }

  void RepeatMe(){
    Debug.Log(Time.time);
  }

https://www.kindacode.com/snippet/unity-how-to-run-a-function-after-a-delay/

TechXR runs courses in AR / VR / Metaverse / Game Development. Some of the popular Q&A in our courses are available here for easy discovery.

113 questions

117 answers

55 comments

105k users

...