hillclimb2d/Assets/Scripts/parallax.cs
2025-03-21 14:18:07 +05:30

22 lines
576 B
C#

using UnityEngine;
public class parallax : MonoBehaviour
{
public Material material;
public float SpeedMult = 1;
public float Speed = 10;
public float distance = 2;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
material = GetComponent <MeshRenderer>().sharedMaterial;
}
// Update is called once per frame
void Update()
{
distance += Time.deltaTime * Speed * SpeedMult;
material.SetTextureOffset("_BaseMap",Vector2.right * distance);
}
}