stacking falling objects on top of each other help


im building a stacking game with objects falling off of a conveyor belt and stack on a platform the player controls. I have the object that falls onto the platform and on top of each other item child to the falling object and apply a Joint Spring. I want the object that is falling to become a child to the platform or object that is stacked on the platform, then Zero out the position of the child object’s XYZ coordinates then lastly apply the Spring Joint. I’ve gotten the script to parent on collision, then zero the transform position, then add a spring joint but the problem im having is the objects start stacking underneath the top object. here’s a video of the problem happening
(Unity Parenting/Child - YouTube)

and here is my script

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

public class IngredientsJointConnect : MonoBehaviour
    SpringJoint springJoint;

    bool hasJoint;
    void OnCollisionEnter(Collision collision)
        if (collision.gameObject.GetComponent<Rigidbody>() != null && !hasJoint)
            gameObject.transform.parent = collision.transform;
            transform.localPosition =;
            gameObject.GetComponent<SpringJoint>().connectedBody = collision.rigidbody;
            hasJoint = true;
            springJoint = GetComponent<SpringJoint>();
            springJoint.spring = 900;
            springJoint.enableCollision = true;
            //springJoint.breakForce = 150;

I would like the objects to stack on top of one another, do I need to add a positive value to the Z position after every collision?


I just want the falling objects to center to the object they are falling on