I would like to move an object and move it faster overtime, to be exact , increase its speed by 0.05f per second.
Below is a script attach to any object that will move from Right to left then to Right again.
using UnityEngine;
public class CountDownText : MonoBehaviour
{
public float minimum = -1000.0F;
public float maximum = 1000.0F;
// starting value for the Lerp
static float t = 0.0f;
void Update()
{
// animate the position of the game object...
transform.localPosition = new Vector3(Mathf.Lerp(minimum, maximum, t), 0, 0);
// .. and increase the t interpolater
t += 0.05f * Time.deltaTime;
// now check if the interpolator has reached 1.0
// and swap maximum and minimum so game object moves
// in the opposite direction.
if (t > 1.0f)
{
float temp = maximum;
maximum = minimum;
minimum = temp;
t = 0.0f;
}
}
}
The movement is of fixed speed somehow, anything i do wrong? Thanks in advance!
Any error that i overlooked