conditional spawning

Hello all. I have a spawn script which instantiates a ball at given coordinates which works great, however I want the ball to be spawned only after a condition is met and I’m not sure how to go about doing that. Right now my script spawns the ball every 10-15 seconds with a startup time of two seconds and is repeated using invokerepeating. I want the Ball however to be spawned and repeated only after the score is equal to or greater than 50. I tried putting the invokerepeating script into an if statement in the update function but when the score was 50 a ball was spawned every frame. This must be a simple fix …but I can’t seem to figure it out, help please?

It is hard to help you if we don’t see any code.

Generally, you should only surround the GameObject.Instantiate call with an if statement. It mustn’t be the best way but it should work. Give us your code and we can help you more.


if (score >= 50)
    GameObject.Instantiate(ballPrefab);