Hi everyone ! I’ve made 3 differents backgrounds for my game and i want them to scroll rightway infinetly so that when once gets off the camera view it will be destroyed and put behind the others and in a random way. Do you have any idea? Thank you very much !
By background you mean textures or objects?
If textures, instead of moving the object consider moving the texture UV offset in material (I’m assuming that your images are already seamless in X direction). You could use transparency to show textures behind and rotate them in different speeds (near camera textures rotates slower).
If objects, you will want to know more about OnBecameVisible and OnBecameInivisible. Instead of destroying, consider reusing it when it goes off screen (read about object pools).
Hi L-Tyrosine and thank you for your reply. Yeah, by ‘background’ i mean textures.
But i can’t undertsand what you mean with ‘moving the texture’ UV offset in material, could you do me an example?
For example with three textures : Sky1, Sky2, Sky3. Thank you
I see. The key here is that you want to randomize the order they appear, right?
Forget about UV offset then (btw check out this link for details on what I was talking about, maybe u use it someday).
What I would do: Create 6 planes, 3 materials (unlit) with the textures, 2 planes for each material, place in a list (I’m assuming one texture take the whole screen). Then by code show one random plane in front of cam, taking the whole view, and another right at side, translate these planes at same speed. At each OnBecameInvisible of a plane, hide it and place another at side again. This would create a perfect scrolling 3 textures random background.
Yeah, scuse me for the late reply. I want to randomize the order they appear. OnBecameInvisible in this case stands for ‘when the texture is out of camera view’, is this alright?
Yes, not the texture itself, but the object that have the material with the texture applied.