using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraMove : MonoBehaviour
{
    public GameObject myObject;

    public float speed;
    public float speedOver;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (myObject.transform.position.x < -484)
        {
            Movement();
        }

        else if (myObject.transform.position.x > -484)
        {
            StopMovement();
        }
    }

    void Movement()
    {
        //stops camera movement at Game Over
        if (myObject.transform.position.y == 457.0f)
        {
            transform.Translate(Vector3.forward * 0 * Time.deltaTime);
        }
        else if (myObject.transform.position.y != 457.0f)
        {
            //Move camera forward at constant rate
            transform.Translate(Vector3.right * speed * Time.deltaTime);
        }
    }

    void StopMovement()
    {
        transform.Translate(Vector3.right * 0 * Time.deltaTime);
    }
}
