parent child object

How to make the plateObj the parent when it is instantiated and the nasiObj to be the child of the parent when instantiated ?

 if (gameObject.name == "base_piring")
        {
            if (Gameplay.cuttingboardS1 == "empty")
            {
                Instantiate(plateObj, new Vector2(338.7f, 337.1f), plateObj.rotation);
                Gameplay.cuttingboardS1 = "piring";
               
            }
        }

        if (gameObject.name == "base_nasi")
        {
            if (Gameplay.cuttingboardS1 == "piring")
            {
                Instantiate(nasiObj, new Vector2(338, 339.7f), nasiObj.rotation);
                Gameplay.cuttingboardS1 = "piringNasi";
                
            }
        }

,How can I make the plateObj to be the parent when instantiated and nasiObj to be the child whrn instantiated

 if (gameObject.name == "base_piring")
        {
            if (Gameplay.cuttingboardS1 == "empty")
            {
                Instantiate(plateObj, new Vector2(338.7f, 337.1f), plateObj.rotation);
                Gameplay.cuttingboardS1 = "piring";
               
            }
        }

        if (gameObject.name == "base_nasi")
        {
            if (Gameplay.cuttingboardS1 == "piring")
            {
                Instantiate(nasiObj, new Vector2(338, 339.7f), nasiObj.rotation);
                Gameplay.cuttingboardS1 = "piringNasi";
                
            }
        }

Have you taken a look at the documentation for instantiate?? One of the arguments of instantiate is a parent transform.



You can also set it afterward:

plate.transform.parent = nasi.transform;

Or vice versa…