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

26 lines
550 B
C#

using UnityEngine;
public class parallaxController : MonoBehaviour
{
public Transform Player;
float prevX;
public parallax[] parallaxes;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
float speed = Player.position.x-prevX;
prevX = Player.position.x;
for(int i =0; i < parallaxes.Length; i++){
parallaxes[i].SpeedMult = speed;
}
}
}