transform set world position

I have a wall which is a childobject of a box which is again a childobject of something else.
I want that wall (for example the western wall of the box) to be on the edge of the screen, but the edge position differs offcourse between all screen sizes (I’m programming for mobile phones).

So I need to set the wall’s transform.z to

cam.ViewportToWorldPoint(new Vector3(1, 1, cam.nearClipPlane)).z;

but I can only set it’s local position. Is there way to set its absolute position and let Unity calculate the correct stuff for its local position relative to the parent?

I think you might be looking for this:

Something along the lines of wall.position = wall.InverseTransformPoint(cam.ViewportToWorldPoint(new Vector3(1, 1, cam.nearClipPlane)).z);?

Edit: hold right there, wth am I talking about, isn’t .position already its global position?

if you want a child to be positioned relative to a parent, it has to have the parent set . ie

cam.transform.parent = parentObject.transform;

you can orient the child relative to the parent using transform.localPosition of the child.