- Home /
make background run loop
how can i make background run and run in loop? i mean when game start player just have action at the sam place but backgrund is runner . so how can i let it run and loop on it?
Errr... I'm afraid I don't entirely understand this question. Can you elaborate? Are you talking about running a process in the background, like a separate thread of execution?
Nope, we're talking about a looping, moving, background image.
material.mainTextureOffset = some Vector2
Seriously, use the search function- this question has been asked at least twice in the last three weeks alone.
Wow. Just, out of curiosity, how did you glean that from the question text alone?
I'd post a proper answer, but it's really basic, this guy can't upvote, and he never marks answers as 'accepted' either...
Answer by save · Oct 25, 2011 at 09:03 AM
It depends on what kind of background you have, if it's just a flat image then syclamoth's answer is a good solution. If it's several objects you can have them in two parented instances where you move the past instance when you're at the middle of the later one. This can for instance be done with triggers:
/* Put this script on both objects */
var otherBackgroundObject : GameObject; //The parent of the other instance
private var bgWidth : float = 500.0; //The width of one background object
function OnTriggerEnter (other : Collider) {
if (!other.CompareTag("Player")) return;
otherBackgroundObject.transform.localPosition.x+=bgWidth*2;
}
Your answer