I would like to scroll a texture from right to left on a plane.
How can I do this ?
I was thinking of making an array with different texture and render one after the other. It would be nice to always have texture on that plane to make it look like skyscrapper in NY.
//scroll main texture based on time
var scrollSpeed : float = .5;
var offset : float;
var rotate : float;
function Update (){
offset+= (Time.deltaTime*scrollSpeed)/10.0;
renderer.material.SetTextureOffset ("_MainTex", Vector2(offset,0));
}
now this works going from left to right but if anyone can tell me how to change which direction it scrolls id really appreciate it. I’m trying to make a water fall but its falling to the left not down lol
If you mean tile, like bricks/windows on a building, play with the Tiling numbers on the material. If you mean animated, then animate the offsets on the material.
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public float scrollSpeed = 0.5F;
public Renderer rend;
void Start() {
rend = GetComponent<Renderer>();
}
void Update() {
float offset = Time.time * scrollSpeed;
rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
}
}