C# How can i get the speed to go up every 5 points

I have a playerMovement class which contains a forwardspeed set to 7.5f, i want it to go up by 1.0f for every 5 points i get. the points is contained in a Score class containing public static int score that increments in game.

I was thinking i could be lazy and do something like:

if(Score.score == 5)
{
    forwardspeed += 1.0f; 
}
  
if(Score.score == 10)
{
    forwardspeed += 1.0f; 
}

But i donโ€™t want to do it that way for obvious reasons :stuck_out_tongue:
Please help! :slight_smile:

Modulus is your friend here:

OnScoreUpEvent(int newScore)
{
    //modulus (lhs % rhs) returns the remainder
    //of lhs divided by rhs. If it's 0, then lhs 
    //must be a multiple of rhs.

    if(newScore % 5 == 0)
        speed += 1;
}