Hi,
Currently I’m making something which includes multiple materials. I wanted to make a scrolling effect so I changed the offset of the material Main Texture to make it happen. This works fine and well. But the moment it’s lerping to another texture it stoppes moving. I used the debugger of Visual studio to check what happens and it seems like the Y-coordinate isn’t affected while lerping.
My scrolling background code:
private void ScrollBackground() {
Vector2 offset = _quadRenderer.material.mainTextureOffset;
offset.y += Time.deltaTime * 0.02f;
_quadRenderer.material.mainTextureOffset = offset;
}
For lerping I used the code which can be found on the Unity Docs:
float lerp = Mathf.PingPong(Time.time, duration) / duration;
rend.material.Lerp(material1, material2, lerp);
My guess is that because of lerping between two materials there is not really a main material present. So my question is: how can I move the material to create a scrolling effect while lerping at the same time?
Thanks in advance!
Kind regards,
Josh