I need a message to displayed every third time I bounce a ball

I have an assignment which requires us to have a ball bounce around a screen with a counter counting every time the ball bounces off an edge.

One of the requirements is to have a message displayed on every 3rd bounce. How would I go about this?

Bit stumped at the moment

Have a number increment every time the ball bounces and if the number of ball bounces is divisible by 3, then display the message:

if(numBounced % 3 == 0)
{
    //display message
}

Have a counter every time the ball bounces. Say its called bounceCounter whose initial value is zero.

void Update()
{
    //When a bounce occurs increment the bounceCounter
    bounceCounter++;
    if(bounceCounter == 3)
    {
        print(" This is a 3rd Bounce");
        bounceCounter = 0;
    }
 }

If you need to keep a track of the total number of bounces as well, another method you can use is

void Update()
{
    //When a bounce occurs increment the bounceCounter
    bounceCounter++;
    if(bounceCounter % 3)
    {
        print(" This is a 3rd Bounce");
    }
 }

Hope this helps!

The problem with @LordTyrion 's script is that it’s called in Update(). Update is called every frame so that statement is being printed every 3 frames, rather than every 3 bounces. You need to make a method that is called every bounce instead. If you’re using Rigidbodies, you can use OnCollisionEnter().