Missing Reference after instatiation

This function is in a parent class

//line to focus on

public virtual void PlaceOnAppliance(GameObject objToPlace)
    {
        ingredientOnAppliance = objToPlace.GetComponent<Ingredient>(); //line to focus on
        Transform objTransform = objToPlace.transform;

        objTransform.parent = transform;
        objTransform.position = top.position;
        objTransform.rotation = top.rotation;
    }

This function is in a child class

public override void PlaceOnAppliance(GameObject objToPlace)
    {
        base.PlaceOnAppliance(objToPlace);

        //check request completion
        if (ingredientOnAppliance.ingredientType == request)
        {
            //consume
            Destroy(ingredientOnAppliance.gameObject);
            Destroy(instantiatedObj);
            ingredientOnAppliance = null;

            GameObject dirtyPlate = kitchenManager.InstantiateIngredient(IngredientType.PlateDirty);
            base.PlaceOnAppliance(dirtyPlate);

            StartCoroutine(NewRequest());
        }
    }

When I call base.PlaceOnAppliance(dirtyPlate);, the dirty plate is placed at the right spot, but the reference to the IngredientOnAppliance is missing, even though the dirtyPlate has that script on it after being instantiated

201535-1.png

In your function

kitchenManager.InstantiateIngredient(IngredientType.PlateDirty);
do you return the reference to the GameObject which is returned by the Unity Function
Instanciate or do you return the Asset Reference?

Please share all of your code, then we can take a closer look at it. :slight_smile: