I need to delete a rigidbody for my group to function. I have dragable parts that join into a group on collision. But the parts still move separately unless I manually delete their rigidbodies. But how do I do this through a c# script? I have tried this:
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;
GameObject.FindGameObjectsWithTag("Part").Destroy(Rigidbody);
}
}
}
But that gives me this error:
Assets/Resources/ObjectAttach.cs(23,67): error CS1061: Type UnityEngine.GameObject[]' does not contain a definition for
Destroy’ and no extension method Destroy' of type
UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)
What do I do?