# Gradually increase camera speed (p.s. using weird float values)

Hey, I’ve been making an arcade-style platformer, the camera goes down the screen. I want the camera to be able to increase speed gradually. However, I am using very weird float values for my speed but they work perfectly. How would I be able to edit my code that it can increase gradually but still use the same float values? Thanks in advance!

// Use this for initialization

void Start () {

}

// Update is called once per frame
void Update () {

transform.Translate(Vector2.down * 0.13f);
if (transform.position.y == 4)
{
transform.Translate(-Vector2.down * 0.13f);
}
if (transform.position.y == -4)

{
transform.Translate(Vector2.down * 0.13f);

}
}

You can just introduce a constant that multiplies by those values and slowly increase that constant:

``````// Set in the inspector
public void  float speedIncreaseTime  // in seconds (0.5 = 1/2 sec)
public void float speedConstantIncrease;
private void speedConstant = 1.0;
private void lastSpeedUpdate = 0.0;

void Start () {

}

// Update is called once per frame
void Update () {

transform.Translate(Vector2.down * 0.13f*speedConstant);
if (transform.position.y == 4)
{
transform.Translate(-Vector2.down * 0.13f*speedConstant);
}
if (transform.position.y == -4)
{
transform.Translate(Vector2.down * 0.13f*speedConstant);
}

lastSpeedUpdate+=Time.deltaTime;
if (lastSpeedUpdate > speedIncreaseTime)
{
speedConstant+=speedConstantIncrease;
lastSpeedUpdate = 0;
}

}
``````

Though I’m a little confused by the following lines they don’t seem to make much sense. Are you trying to make the camera bounce up and down? Is it just boundary checking? What are you trying to do with this code:

``````   transform.Translate(Vector2.down * 0.13f);
if (transform.position.y == 4)
{
transform.Translate(-Vector2.down * 0.13f);
}
if (transform.position.y == -4)
{
transform.Translate(Vector2.down * 0.13f);
}
``````

Im trying to make it go down the screen, i followed a youtube tutorial for the code.