combining/compounding ridged body's in code

I want on collision for objects that match certain tags to combined into a compound ridged body connecting them at the point of collision

P.S. i know i can do this with joints but I want the connection to be a lot more stable and them to behave as a single object after attachment

According to the video that you posted, it seems like you want to make all the objects stick together…
To accomplish this you can maybe create a new empty Gameobject and make the two objects that you need to connect a child of that empty gameobject

Ok so, I have been working on a solution for the past hour and I think I found one.
The solution is as follows :


1.Create 3 tags (“Joint”, “JointBox” and “Box”)
2. Assign “Box” to the object that you want to move
3. Assign “Joint” to the ‘Joiner’ object (That joins 2 or more objects)
4. Add a Collider to the ‘Joiner’ object and make it a ‘Trigger’
5. Then create a new script called “PickupObject” (It should be added to the ‘Player’) and type the following :

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

public class PickupObject : MonoBehaviour
{
    [SerializeField] private Camera FPSCam; //This is the main camera
    [SerializeField] private float Range; //This is the range of the Raycast
    [SerializeField] private float ZDistance; //This sets how far you want to hold your object
    [SerializeField] private GameObject Joint; //This the the 'Joiner' object
    
    void Start()
    {
        
    }

    void Update()
    {
        if (Input.GetMouseButton(0))
        {
            MoveObj();
        }
        else if(Input.GetMouseButtonDown(1))
        {
            JoinObj();
        }
    }

    public void MoveObj()
    {
        Vector3 MousePos = Input.mousePosition;
        RaycastHit hit;
        if (Physics.Raycast(FPSCam.transform.position, FPSCam.transform.forward, out hit, Range))
        {
            if (hit.transform.tag == "Box")
            {
                GameObject Obj = hit.transform.gameObject;
                Obj.transform.position = FPSCam.ScreenToWorldPoint(new Vector3(MousePos.x,MousePos.y, ZDistance));
            }
            else if(hit.transform.tag == "Joint")
            {
                GameObject Obj = hit.transform.gameObject;
                Obj.transform.position = FPSCam.ScreenToWorldPoint(new Vector3(MousePos.x,MousePos.y, ZDistance));
            }
        }
    }

    public void JoinObj()
    {
        RaycastHit hit;
        if (Physics.Raycast(FPSCam.transform.position, FPSCam.transform.forward, out hit, Range))
        {
            if (hit.transform.tag == "Box")
            {
                Instantiate(Joint, hit.point, Quaternion.identity);
            }
        }
    }
}

5.Then create another new script called “JoinBox” (It should be added to the ‘Joiner’ object) and type the following in it :

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

public class JoinBox : MonoBehaviour
{
    
    void Start()
    {
        
    }

    void Update()
    {
        
    }

    private void OnTriggerStay(Collider other)
    {
        if (other.tag == "Box")
        {
            other.transform.parent = this.gameObject.transform;
            other.gameObject.tag = "JointBox";
        }    
    }   
}

I’m pretty sure this will work because i have tested it multiple times in Unity…
***IMPORTANT NOTE : *** To move 2 joint objects, you have to select the ‘Joiner’ object that is connecting them

A fixed joint will give one of the rigidbodys full control. Set the break force to infinity and it will be like you have a single rigidbody entity. Otherwise, just set the rigidbodys that you want to have follow as children of the rigidbody you want to control and set the rigidbody.isKinematic = true on each of the children. Those are pretty much your only 2 options based on your use case.



here is an example of what i want it to look like when it is complete.

fixed joint just flop around i don’t want the joint to be able to move
if you parent one object you can only pick up and move via the parent where as in the example they can pick up any object and it moves as a structure regardless of the pick up point