Strange lighting due to inconsistent Z-position after setting parent

I’m making an Android AR app and I’m trying to augment a few gameobjects on a glass plate in AR. For this i have a plate game object and I’m trying to place the child gameobjects on that plate by making the plate as parent. But when I set the plate as parent of child the child objects have inconsistent z position even if I try to set its z position as the z position of parent explicitly.

  1. I set the x&y positions of the child and set its Z to the parent’s z
  1. I set the plate as the parent of child and log their positions before setting parent and after setting parent
Debug.Log("Parent Z value : " + parent.transform.position.z);
Debug.Log(" Before setting parent, Child Z value : " + child.transform.position.z);

child.transform.SetParent(parent.transform, true);

Debug.Log(" After setting parent, Child Z value : " + child.transform.position.z);
  1. The logs I got had Z value different after setting parent which shouldn’t happen as child and parent both have had the same Z-values since their instantiation :

Parent Z value : 0.2666564

Before setting parent, Child Z value : 0.2666564

After setting parent, Child Z value : 0.308827

The changed z value also is different for all the child objects. This is causing the gameobjects to light up randomly when I move my phone camera around.

1 Like

I see a similar issue, but not sure it this is happening because of the z-axis or lighting in the scene.