I want to repeat texture on Quad but it is not repeating
here is my code
using UnityEngine;
using System.Collections;
public class Track : MonoBehaviour {
public float speed;
Vector2 Offset;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Offset = new Vector2 (0, Time.deltaTime * speed);
GetComponent<Renderer> ().material.mainTextureOffset = Offset;
}
}
please someone help
You have logic problem when assigning value to
Offset
. Explanation below:As you can see now, you're only assigning the value which will be almost the same every time. The value can vary only a bit just because of
Time.DeltaTime
will yield delta time between frames which can be approximately0.0016f
.So to make it clear, you should not rely on
Time.DeltaTime
because it's almost constant value. First try to initialize yourOffset
inStart
orAwake
method:Then inside of your
Update
method you can just increaseX
value :