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.