Question by
ThunderstruckGames · Nov 22, 2020 at 04:47 PM ·
c#scripting problembackground
How do I fix my scrolling background,How do I fix my scrolling background?
I am creating a space 2D shooter game and currently trying to create a scrolling background. However, I have got the scrolling part to work but when it's scrolling it appears to have seams done it time and time again. How would I fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BGScroll : MonoBehaviour {
public float scroll_Speed = 0.1f;
private MeshRenderer mesh_Renderer;
private float x_Scroll;
void Awake() {
mesh_Renderer = GetComponent<MeshRenderer>();
}
// Update is called once per frame
void Update() {
Scroll();
}
void Scroll() {
x_Scroll = Time.time * scroll_Speed;
Vector2 offset = new Vector2(x_Scroll, 0f);
mesh_Renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
}
}
// Class
,I am working on a 2D shoot em up game and trying to apply a scrolling background. However, I have got the scrolling side of it working but my only problem seems to be that my background appears to have seams in it when it scrolls. Any ideas?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BGScroll : MonoBehaviour {
public float scroll_Speed = 0.1f;
private MeshRenderer mesh_Renderer;
private float x_Scroll;
void Awake() {
mesh_Renderer = GetComponent<MeshRenderer>();
}
// Update is called once per frame
void Update() {
Scroll();
}
void Scroll() {
x_Scroll = Time.time * scroll_Speed;
Vector2 offset = new Vector2(x_Scroll, 0f);
mesh_Renderer.sharedMaterial.SetTextureOffset("_MainTex", offset);
}
}
// Class
Comment