I have a series of scripts that allow a part to be dragged around my scene. If two parts collide, they are both childed in a gameobject called Group1. But when I then go to drag them, they are dragged separately, but they are still in the same ‘group’. Here is the code I use for attaching the objects:
using UnityEngine;
using System.Collections;
public class ObjectAttach : MonoBehaviour {
public Transform Group1;
void Start()
{
Group1 = GameObject.FindWithTag("Group").transform;
}
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag=="Part")
{
collision.transform.parent = Group1;
}
}
}