- Home /
any way to access the global position and rotation of a child object?
"Object A" moves around the terrain through player input. "Object B" is a child of object A (childed by dragging on to object A in hierarchy). In the inspector, I can see The transform.position and transform.rotation of "Object A" updates as it moves around the map. However, the transform.rotation and transform.position of "Object B" does not update at all, so when I reference its values through script, I always get the same 0,0,0 no matter where "Object B" is.
"Object B" is a spawn point for a bullet and "Object A" is the FPS controller. Bullets are instantiated and moved to the transform values of "Object B" (spawn point), but they do not appear in the right place because the transform of object B does not update.
how can I access the global transform.position and global transform.rotation of "Object B"?
Answer by Jessespike · Jun 15, 2016 at 05:54 PM
transform.position - The position of the transform in world space.
transform.localPosition - Position of the transform relative to the parent transform.
transform.TransformPoint - Transforms position from local space to world space. Note that the returned position is affected by scale.
transform.rotation - The rotation of the transform in world space stored as a Quaternion.
transform.localRotation - The rotation of the transform relative to the parent transform's rotation.
Your answer
Follow this Question
Related Questions
How Do I Give Two Objects the Same Transform? 1 Answer
Possible way to improve performance moving large hierarchies? 1 Answer
Coroutine - transform for every frame for duration? 0 Answers
Issues with copying Y axisrotation of another object 2 Answers
Changes of Transform cancel on next frame after change 1 Answer