how to slow down speed increase?

I am using this script on a space ship, the negative values make the ship go in reverse. it works exactly as I want it to, except I want the speed to increase more slowly, I would like the speed to increase by 10 units a second. can someone give me some tips as to how I would achieve this

``````using UnityEngine;
``````

using System.Collections;

public class SpeedControl : MonoBehaviour {

``````[SerializeField]
float speed = 2.0f;

public float trueSpeed = 0.0f;
public static string speedDisplay;
// Use this for initialization
void Start () {

}

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

float power = Input.GetAxis("Power");

if (trueSpeed < 100 && trueSpeed > -30){
trueSpeed += power;
}
if (trueSpeed > 100){
trueSpeed = 99.99f;
}
if (trueSpeed < -30){
trueSpeed = -29.99f;
}
if (Input.GetKey("backspace")){
trueSpeed = 0;

}
speedDisplay = trueSpeed.ToString("0.0");

}

}
``````

If you want the acceleration to be slower, but keeping the min/max speed, changing:
float power = Input.GetAxis(“Power”);

into:
float power = Input.GetAxis(“Power”)*0.5f;

This does not increase by 10 per second, because the whole point of the script is to handle the stick from a gamepad (the more you push it, the more it accelerates).

For a flat increase, you would want your “power” to use a hard number.

For a stable 10 per second, you would need to multiply 10 with Time.deltaTime (see Unity - Scripting API: Time.deltaTime for an example)

Alternatively you could utilize : Unity - Scripting API: Mathf.SmoothDamp

``````	float velocity = 1.0f;
float currentSpeed = 0.0f;
float maxSpeed = 100.0f;
float dampen = 25.0f;
void Update () {
currentSpeed = Mathf.SmoothDamp(currentSpeed, maxSpeed, ref velocity, Time.deltaTime * dampen);
Debug.Log(currentSpeed);
}
``````