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

public class PlataformaMovil : MonoBehaviour
{
    private Rigidbody2D rb;
    private int dir;

    void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    

    void Update()
    {
        if (transform.localPosition.x < -7)
        {
            dir = -1;
            //rb.MovePosition(transform.position + transform.right * 5 * Time.deltaTime);
        }else if(transform.localPosition.x > 6)
        {
            dir = 1;
            //rb.MovePosition(transform.position - transform.right * 5 * Time.deltaTime);
        }


            rb.MovePosition(transform.position - transform.right * 5 * dir *Time.deltaTime);

    }
}
