Made it so that speed boost/slowDown effect is gone after some time using Coroutines.
int moveSpeed;
Coroutine? moveSpeedEffect;
void ChangeMoveSpeed(int newSpeed) {
if (moveSpeedEffect != null) {
StopCoroutine(moveSpeedEffect);
}
moveSpeed = newSpeed;
moveSpeedEffect = StartCoroutine(ChangeMoveSpeedBackToNormal());
}
IEnumerator ChangeMoveSpeedBackToNormal() {
yield return new WaitForSeconds(moveSpeedEffectDuration);
moveSpeed = normalMoveSpeed;
moveSpeedEffect = null;
}
Also made backwards movement slower as well as fixed steering when moving backwards - when you move backwards and steer left - it moves left instead of right.
if (move >= 0) {
steer *= -1;
} else {
move /= 2;
}
transform.Rotate(Vector3.forward, steer * steerSpeed * Time.deltaTime);
transform.Translate(0, move * moveSpeed * Time.deltaTime, 0);