Rails movement

Hi guys i need some help i explain on pictures.

i need move objects on platform by direction example on this picture.

2876313--210943--upload_2016-12-6_12-9-2.png

So it’s simle the red box is a cube and gray rectanlge is the platform and i want platform move cube to arrow directions. i’m trying witih rigidbody and transform but got some errors. because if the box have rotation 90 - 90 -180 180 they move wrong direction. can u help me a clean and simple code?

Done: :smile:

        if (_start.transform.position.x < _end.transform.position.x)
        {
            collision.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(1f* Vector2.right.x, 0);
        }
        else
        {
            collision.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(1f * -Vector2.right.x, 0);
        }

Is this like conveyor belt style movement? There’s a Surface Effector 2D component that you can put on your platform to move rigidbodies along it automatically.