I have a script that on the collision of two 'parts' one is parented under the other. If I drag the parent object, both objects are moved, but if the child is dragged, only the child moves. I don't know how I can fix this, as I want both objects to remain attached no matter if the parent of child is moved. Here is my script:
using System.Collections;
public class ObjectAttach : MonoBehaviour {
void Start()
{
}
void OnCollisionEnter(Collision collision)
{
if(collision.gameObject.tag=="Part")
{
collision.transform.parent = transform;
}
}
}
↧