I am having trouble increasing score based on speed of the car with a few lines of code. I know how to do it with score vs time with
, and I know how to this with 5 or 6 conditions and 20 lines of code ,but I wanted to do this with a few lines of code. It’s possible ?.
What I want is:
Score + = 1 point every 1 second if car speed = 1.
Score + = 1 point every 0.8 seconds if car speed = 3
Score + = 1 point every 0.6 seconds if car speed = 6.
Score + = 1 point every 0.4 seconds if car speed = 9.
Score + = 1 point every 0.2 seconds if car speed> 9.
I m using two Coroutines, one for score and another for speed, activated on Start function:
private IEnumerator ChangeSpeed()
{
while (true){
yield return new WaitForSeconds(1);
if(speed < 2.0f || speed < 9.0f && gameStart){
speed += 3.0f;
}
if(speeding)
velocity = speed + 1f;
else
velocity = speed;
}
}
private IEnumerator ChangeScore()
{
while (true){
yield return new WaitForSeconds(1);
if(gameStart){
scoreNum += 1;
scoreText.text = scoreNum.ToString();
}
}
}