Okay let me set this up for you guys. I have a bowl and I have tennis balls that slowly fall into the bowl.
I have scripts set up on the bowl and the balls so that it can count how many tennis balls have entered the bowl. I want to now create a script that every 30 seconds, the tennis balls get counted and if there are 8 or less balls in the bowl, destroy all balls (essentially empty the bowl) BUT if there are 9 or MORE balls in the bowl, it’s game over (bowl overflow)
here’s the scripts that I have attached to the Ball:
public int Balltocount;
void OnCollisionEnter(Collision other)
{
if (other.gameObject.tag == "Bowl")
{
other.gameObject.GetComponent<BallCounter>().CountBalls(Balltocount);
}
}
}
And this is what I have on the BOWL:
public int Counter;
public void CountBalls(int howmany)
{
Counter -= howmany;
}
}
this works fine and is able to count the balls colliding in the bowl, its just the next step that i mentioned above that i cant figure out. Thanks to anyone who takes a look at this.