My God! What a long road it took to get this basic function to work! With a little help from one of my classmates, we came up with the right code to allow my environment to scroll in the way that I want it to. Looking back on it, I can’t believe that I went through tens of lines of code just to see that it only took close to 20 lines. *sigh* My programming skills really need some brushing up, but that’s what this upcoming winter break is for! Anyways, below is the script when inserted in my gameobject “scrollTerrain”:
var topSpeed = 20.0;
var minSpeed = 1.5;
var currentSpeed : float;
var acceleration : float = 5.0;
function Start () {
currentSpeed = minSpeed;
}
function FixedUpdate (){
currentSpeed = Mathf.Clamp(Time.time, minSpeed, topSpeed);
}
function Update () {
currentSpeed += Time.deltaTime * acceleration;
transform.Translate(-currentSpeed * Time.deltaTime, 0, 0);
}
Onward to completing the rest of the game’s features now that this great hurdle is over with, and what I’ve learned from it is to never be too proud to ask for a little help. It could go a long way! As always, keep gaming.