Description
The LocalPosition
property of a GameObject
represents its position relative to its parent. If the GameObject
has no parent, this position is relative to the scene's origin. This property is useful for positioning the object within a local coordinate system, allowing for hierarchical transformations where the position of a child object is dependent on its parent's position.
Usage
To get or set the local position of a GameObject
, use the LocalPosition
property. This property is of type Vector3
, which means it contains three components: X, Y, and Z, representing the position in 3D space.
Example usage:
GameObject myObject = new GameObject();
// Set the local position
myObject.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);
// Get the local position
Vector3 position = myObject.LocalPosition;
Example
GameObject myObject = new GameObject();
// Set the local position
myObject.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);
// Get the local position
Vector3 position = myObject.LocalPosition;