rigidbody2d on a moving stage

Hello everyone

I am working on a 2D game and i have rigidbody which is going to move with a moving stage.
The problem is that if the object is not the child of the stage it fall of the stage
but i can’t make in a child because it is a rigidbody2D.

(C#)

what should i do?
thanks for the help

Never mind I have made my own code(C#) to solve the problem .
Do let me know if there is any problems or things you want me to change in the code,
but if you know how to solve the problem do let me know.
thanks for the help.

using UnityEngine;
using System.Collections;

public class rigidMoveStage : MonoBehaviour {
public float Xdistance;
public float Ydistance;
public Vector2 vector;
public Vector2 stageVector;
public bool colBool = false;

//this code needs to be on the colliding object
//do let me know if there is any problem


// Update is called once per frame
void Update () {
    GameObject colObject = GameObject.Find("col");
    if (colBool == true) {
        //without gravity(locks y axis)
        this.gameObject.transform.position = new Vector2(stageVector.x + Xdistance, stageVector.y + Ydistance);
        
        
        //with gravity(unlocks y axis)
        //this.gameObject.transform.position = new Vector2(stageVector.x + Xdistance, this.gameObject.transform.position.y);            

        stageVector = colObject.gameObject.transform.position;
    }
}
void OnCollisionEnter2D(Collision2D col) {
    vector = transform.position;
    stageVector = col.gameObject.transform.position;

    col.gameObject.name = "col";

    Xdistance = vector.x - stageVector.x;
    Ydistance = vector.y - stageVector.y;

    colBool = true;

    //feel free to use it
    
}

}