Quantcast
Channel: Questions in topic: "invokerepeating"
Viewing all articles
Browse latest Browse all 220

How to run InvokeRepeating for x amount of seconds?

$
0
0
So in my code I currently have this: public GameObject enemyPrefab; Vector3 position = new Vector3(81.5f, 1.859728f, 4.802853f); // Use this for initialization void Start() { InvokeRepeating("SpawnEnemy", 0.0f, 1f); } // Update is called once per frame void Update () { } void SpawnEnemy() { Instantiate(enemyPrefab, position, Quaternion.identity); } What I need is for InvokeRepeating to only run a certain number of times. For example, having an integer that represents the amount of times I need it to run.

Viewing all articles
Browse latest Browse all 220

Trending Articles