If a player receives X amount of points for doing something in my game I want the scoreboard to update showing each number from 0 - X very briefly. I’m going for an analog style scoring system like those old clocks where you can watch the numbers change, except the change will happen quickly because hundreds of points can be added at the same time.
Currently, X amount of points are updated instantly when points are awarded:
/****************************** Platform Collision ***************************/
void OnCollisionEnter2D(Collision2D coll)
{
foreach(ContactPoint2D contact in coll.contacts)
{
newPlayerHeight = transform.position.y;
// Don't count the first jump
if(newPlayerHeight < 0){
newPlayerHeight = 0;
}
// If the player jumps down, don't reduce points
// Add a tolerance for variable collision positions on same platform
if(newPlayerHeight < oldPlayerHeight + -0.05f){
newPlayerHeight = oldPlayerHeight;
}
// Send the height to the Score class
Score.SP.updateScore(newPlayerHeight);
oldPlayerHeight = newPlayerHeight;
}
}
/******************************* Score class *********************************/
public void updateScore (float newScore)
{
// Display GUI score
score = (int)(newScore * 76);
guiText.text = "Score" + score;
}
I messed around with a for-loop to try and achieve this but got nowhere close.