Child nodes absolute world position

How do I get a child objects absolute world position not just the position relative to its parent element?

I have a Gameobject container that is moved around, the Playership. Grouped below it are are a few subobjects like Gunsockets, the ShipMesh or a TargetBeaconPrefab. How do I get the absolute world position of the TargetBeaconPrefab? Is there a easyer way then adding the Playership and TargetBeaconPrefab Transforms? What if I dont know about a objects hiarchy?

// Show position in console for debuging
Debug.Log(TargetBeaconPrefab.transform.position.ToString()) ;

Returns the Childs “local position” in World Space. Stays at 0,0,0 regardless of the Playerships movement.

The TargetBeaconPrefab can be linked to weapons as a AimTarget. This allow enemy weapons to shoot at the player. This way I could add a Position subobject to track the movement of any complex object without adding a script or needing to convert it to a prefab first.

How do I access its real world position. Till now I can only access its position relative to its parent. The docs say transform.position is in WorldSpace but it seems to return child level transforms only.

You may add parents and childs positions to get world position

var worldPosition = transform.position + transform.parent.transform.position;

I just tested this, and in my test scene, Transform.position does in fact appear to refer to the object’s world position. Are you sure your diagnostic is correct?

Also, instead of this:

Debug.Log(TargetBeaconPrefab.transform.position.ToString());

You should be able to write:

Debug.Log(TargetBeaconPrefab.transform.position);

I found the error. I linked to the wrong prefab instance. transform.position realy returns the world position just fine. Thanks for your help.