- Home /
Question by
Daniloleemes · Jul 29, 2015 at 11:53 AM ·
texturesbackground
Runner Game Background Softly Change
Hi guys, I'm making a runner game like Jetpack Joyride. I made a script to move my background using a second camera + a "Quad". Well, what I don't have any ideas of how to do is changing the background softly once my script just set a new texture to the Quad. Ex.: There is a texture running, a few seconds later, BOOM, other texture is there. My script for changing the background is something like this
@edit: full script here:
public class ScrollScript : MonoBehaviour {
public float speed = 0;
public Renderer rend;
public Texture[] Cenario;
private float tempo;
private int i = 0;
void Start() {
rend = GetComponent<Renderer>();
tempo = 0;
}
// Update is called once per frame
void Update () {
tempo += Time.deltaTime;
rend.material.mainTextureOffset = new Vector2 (Time.time * speed, 0);
while (i <= 7 && tempo >= 2) {
rend.material.mainTexture = Cenario[i];
i++;
tempo = 0;
if (i == 7) i = 0;
}
}
}
Comment
Your answer
