- Home /
Question by
TheBloop · Sep 24, 2020 at 11:02 PM ·
materialbugbackgroundscroll
Material smudge on parallax background scroll
I have a background that has to scroll infinitely. I saw some tutorials on Youtube and this is the code I have:
public class BackgroundScroll : MonoBehaviour
{
[Range(-1f, 1f)]
public float scrollSpeed = 0.5f;
private float offset;
private Material mat;
void Start()
{
mat = GetComponent<Renderer>().material;
}
void Update()
{
offset += (Time.deltaTime * scrollSpeed) / 10f;
mat.SetTextureOffset("_MainTex", new Vector2(offset, 0));
}
}
It all works great except When the material completes one loop, it sort of becomes like a smudged image:
Notice how it looks in the end. How do I fix it? is it a problem with my material?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613012510im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera background glitches, drawing multiple images of gameobjects on the background 0 Answers
Problem using multiple materials 0 Answers
Standard material shader ignoring SetFloat property "_Mode"? 1 Answer
Textures go black when changing Quality Settings at runtime 0 Answers
iOS simple shader does not work 1 Answer