using UnityEngine;

public class ParalaxMovment : MonoBehaviour
{
    [SerializeField]
    private float parallaxFactor = 1.0f;
    private Vector3 startPosition;
    private float previousCameraPosition;

    void Start()
    {
        startPosition = transform.position;
        previousCameraPosition = Camera.main.transform.position.x;
    }

    void Update()
    {
        float cameraMovement = Camera.main.transform.position.x - previousCameraPosition;

        Vector3 newPos = startPosition + Vector3.left * cameraMovement * parallaxFactor;

        transform.position = newPos;

        previousCameraPosition = Camera.main.transform.position.x;
    }
}
