[Solved] Attach an object to another object [closed]


if (Input.GetMouseButtonDown(0)) {
     RaycastHit hit;
     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit))
         if (hit.collider == this.gameobject) // this can be checked on parent or child, your call
         this.transform.parent = yourParentObject;            
}

1

solved Attach an object to another object [closed]