increasing balls number !

Hello guys
i want to make my balls number increase 1 or 5 or any number of balls when the timer is more than or equal 30 for example,
for one time not every frame ,if i put the code in function update the balls number will increase every frame , and if i wrote my code without function Update it doesn,t work !!

var BallsNum =10 ; 

function Update(){
 if (Timer.Timer>=30){
 
BallsNum+=5;
}
}

var BallsNum =10 ;
bool isIncreased=true;
function Update(){
if(Timer.Timer>=0&&Timer.Timer<=30 && isIncreased)
isIncreased=false;
BallsNum+=5;
}

This will excute only one time … I hope this is what you want

This is written in C#, but it sounds like this is what you’re looking for. What may have been happening (and I’m not too familiar with the “Timer” variable) is tht you never restart any timer, so after the timer goes above 30 it’s always above 30, making the ball increase constantly.

int BallsNum = 10;
float timerCountDown = 30;

void Update()
{
  timerCountDown -= Time.deltaTime;
  
  if(timerCountDown<=0)
  {
    BallsNum+=5;
    timerCountDown = 30;
  }


}

work with Time.deltaTime. Try:

public var Timer : float

function Update () {

   Timer += time.deltaTime;

      if (Timer > 30){
       \\ Happy Code :3
      }

}

A simple way to have five balls at one press of a button is to duplicate the empty gameObject and place it a little bit far so that the balls don’t collide with each other.