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");
rigidbody.AddRelativeForce(0,0,trueSpeed*speed*Time.deltaTime);
}
}