Connecting parts together

Hello unity community

was looking for a bit of advise/direction. I want to build a small garage mechanics game, ive made a 3rd person character which I can move around the garage but now I want to be able to build a car by choosing different parts (wheels, doors, spoiler etc)scattered around the garage. What route should I take? Should I just use rigid bodies. I’ve been reading up on joints in unity, is that a good option? Or is there another option I should look into. Any advise is appreciated.

Keep the constructed item separate from the blocks, use the items scattered around the garage as a “menu” dont bother trying to actually attach them.

Then theres 2 ways you can construct your vehicle.

Make a monster vehicle that has every single 3D object possible attached to it, but turn off activation for game objects that are not selected, making them “invisible”

OR make a frame out of invisible game objects that are “position holders”. When a certain door is selected, instantiate it at the “door position holder game object” location.

I wouldnt work with joints at all unless there was a good reason too, keep it simple. Remember instantiating a new door or adding every single possible door, in a game, is cheap :slight_smile:

@PresleyPreston i would like to help, I have modified a script for DragRigidbody so that on collision with an object tagged “Snappable” it attaches a fixed join to the blocks or parts together. `public class DragRigidbody : MonoBehaviour
{
private bool isBuild;
private Quaternion Rot;
public string BuildKey = “b”;
const float k_Damper = 5.0f;
const float k_Drag = 1.0f;
const float k_AngularDrag = 5.0f;
const float k_Distance = 0.2f;
const bool k_AttachToCenterOfMass = false;

    private FixedJoint m_FixedJoint;
    bool hasJoint;

    private void Update()
    {
        if (Input.GetKeyUp(BuildKey) == true)
        {
            isBuild = !isBuild;
        }
        if (isBuild != true)
        {
            gameObject.GetComponent<Rigidbody>().useGravity = true;
            gameObject.GetComponent<Rigidbody>().freezeRotation = false;
            return;
        }

        gameObject.GetComponent<Rigidbody>().freezeRotation = true;
        gameObject.GetComponent<Rigidbody>().useGravity = false;
        // Make sure the user pressed the mouse down
        if (!Input.GetMouseButtonDown(0))
        {
            gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
            return;
        }
        var mainCamera = FindCamera();

        // We need to actually hit an object
        RaycastHit hit = new RaycastHit();
        if (
            !Physics.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition).origin,
                             mainCamera.ScreenPointToRay(Input.mousePosition).direction, out hit, 100,
                             Physics.DefaultRaycastLayers))
        {
            return;
        }
        // We need to hit a rigidbody that is not kinematic
        if (!hit.rigidbody || hit.rigidbody.isKinematic)
        {
            return;
        }

        if (!m_FixedJoint)
        {
            var go = new GameObject("Rigidbody dragger");
            Rigidbody body = go.AddComponent<Rigidbody>();
            m_FixedJoint = go.AddComponent<FixedJoint>();
            body.isKinematic = true;
        }

        m_FixedJoint.transform.position = hit.point;
        m_FixedJoint.anchor = Vector3.zero;
        m_FixedJoint.connectedBody = hit.rigidbody;

        StartCoroutine("DragObject", hit.distance);
    }

    private IEnumerator DragObject(float distance)
    {
        var oldDrag = m_FixedJoint.connectedBody.drag;
        var oldAngularDrag = m_FixedJoint.connectedBody.angularDrag;
        m_FixedJoint.connectedBody.drag = k_Drag;
        m_FixedJoint.connectedBody.angularDrag = k_AngularDrag;
        var mainCamera = FindCamera();
        while (Input.GetMouseButton(0))
        {
            var ray = mainCamera.ScreenPointToRay(Input.mousePosition);
            m_FixedJoint.transform.position = ray.GetPoint(distance);
            yield return null;
        }
        if (m_FixedJoint.connectedBody)
        {
            m_FixedJoint.connectedBody.drag = oldDrag;
            m_FixedJoint.connectedBody.angularDrag = oldAngularDrag;
            m_FixedJoint.connectedBody = null;
        }
    }

    private Camera FindCamera()
    {
        if (GetComponent<Camera>())
        {
            return GetComponent<Camera>();
        }

        return Camera.main;
    }
    void OnCollisionEnter(Collision collision)
    {

        if (collision.gameObject.GetComponent<Rigidbody>() != null && !hasJoint && tag == "Snappable" && isBuild)
        {
            gameObject.AddComponent<FixedJoint>();
            gameObject.GetComponent<FixedJoint>().connectedBody = collision.rigidbody;
            hasJoint = true;
        }
    }
}`