How can i add a child to a parrent without changing the transfom of the child ?
HI,
I am struggling some days to find a way to make a Gameobject child of a prefab that is being loaded during runtime without changing its transform.
I am using Afroundation to load a prefab over a target with a play button and when the button is pressed a tv prefab is presented over an image target in order to play a video.
The tv (child) has a transform of zero in order to be in the center
this.transform.position = new Vector3(0.0f, 0.0f, 0.0f);
this.transform.rotation = Quaternion.identity;
this.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
but when the prefab makes this tv a child of it all the transform. position and the rotation go crazy by changing all the time and the tv goes to a random position with a random rotation.
I even tried to correct it within the update but still nothing.
When I load the prefab (parent) I correct its position and rotation in order to follow the target
void Place (GameObject obj, Vector3 newPosition, Quaternion newRotation)
{
obj.transform.position = newPosition;
obj.transform.rotation = newRotation;
}
can anyone help me here?
I cannot make sense of the error..