Script that mimics a child object behavior.

I need this script, because for some complex reason, I must not attach this object as the child at all cost.

So what exactly is followed by the child object’s transform and the parent object?

This child object will be far away from the target parent, and I need to replicate the behavior of how a child object works, any help?

C# preferred.


Are you sure that you want to make it be absolutely like child? If a far “parent” object? A little rotation or “parent” may cause a huge movement of “child”. But you can make it rotate synchronously around it’s own pivot.

public GameObject ala_parent;
Vector3 d_rotation, d_position, d_scale;

void Start() {
  d_rotation = Quaternion.FromToRotation(ala_parent.transform.up, transform.up);
  d_position = transfom.position - ala_parent.transform.position;
  p_scale = new Vector3(transfom.localScale.x/ala_parent.transfom.localScale.x, transfom.localScale.y/ala_parent.transfom.localScale.y, transfom.localScale.z/ala_parent.transfom.localScale.z);

void Update() {
  transform.position = ala_parent.transform.position + d_position;
  transform.rotation = d_rotation * ala_parent.transform.rotation;
  transform.localScale = Vector3.Scale(ala_parent.transform.localScale, d_scale);