Using this thread, I am attempting to get a side scrolling picture constantly. Once the game has started, it renders the picture then lines as it moves right.
Not sure what is going on. Any help is appreciated.
public class ScrollScript : MonoBehaviour {
public float speed = 0.25f;
public Renderer rend ;
// Use this for initialization
void Start () {
rend = GetComponent ();
}
// Update is called once per frame
void Update () {
rend.material.mainTextureOffset = new Vector2 (Time.time*speed,0f);
}
}
It seems to me like that should work. I created a script to do pretty much the exact same thing, and it worked fine when attached to an object with a texture renderer. Are you getting any errors?
Here’s my script:
public class TextureScroll : MonoBehaviour
{
public float horizontalScrollSpeed = 1f;
public float verticalScrollSpeed = 0f;
Renderer myRenderer;
void Start ()
{
myRenderer = GetComponent<Renderer> ();
}
void Update ()
{
myRenderer.material.mainTextureOffset = new Vector2 (Time.time * horizontalScrollSpeed, Time.time * verticalScrollSpeed);
}
}