Reputation: 47
New to Unity, trying to recreate the scrolling background effect found in this asset pack but cannot find anything online. https://pixel-frog.itch.io/pixel-adventure-1.
Upvotes: 1
Views: 113
Reputation: 321
You could just create a quad with the checkerboard pattern material on it and then change the texture offset programmatically.
I didn't actually test this code out but here's some code:
public class AnimatedBackground : MonoBehaviour
{
public float scrollSpeed = 0.5f;
private Material material;
private float offset = 0.0f;
void Start()
{
material = GetComponent<MeshRenderer>().sharedMaterial;
}
void Update()
{
offset += Time.deltaTime * scrollSpeed;
material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
}
}
Of course, if you want more than one checker then you can adjust the scale of the texture in the material properties.
Upvotes: 1