Conveyor belt scrolling texture

This commit is contained in:
nothke
2024-08-17 11:34:12 +02:00
parent 62cadfb78a
commit c3c816445f
6 changed files with 1431 additions and 332 deletions

View File

@@ -11,6 +11,10 @@ public class ConveyorBelt : MonoBehaviour
Vector3 startPosition;
float scrollingTextureProgress = 0;
public float scrollingTextureSpeedMult = 1;
public Renderer scrollingTextureRenderer;
private void Start()
{
startPosition = rb.position;
@@ -22,4 +26,14 @@ public class ConveyorBelt : MonoBehaviour
Vector3 targetSpeed = speed * transform.forward;
rb.MovePosition(rb.position + targetSpeed * Time.deltaTime);
}
private void Update()
{
if(scrollingTextureRenderer)
{
scrollingTextureProgress += Time.deltaTime * speed * scrollingTextureSpeedMult;
scrollingTextureRenderer.material.SetTextureOffset("_MainTex",
new Vector2(0, scrollingTextureProgress));
}
}
}