Description
The LocalPosition
property represents the local position of the game object within its parent. It is a Vector3
value that specifies the position of the game object relative to its parent object's origin. This property is useful for manipulating the position of a game object in a local context, allowing for transformations that are relative to the parent object rather than the world.
Usage
To use the LocalPosition
property, you can get or set its value to adjust the position of the game object relative to its parent. This is particularly useful when you want to move a game object within a hierarchy without affecting its global position.
Example
// Example of setting the LocalPosition of a component
Component myComponent = someGameObject.GetComponent<Component>();
myComponent.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);
// Example of getting the LocalPosition of a component
Vector3 currentLocalPosition = myComponent.LocalPosition;
// Adjusting the LocalPosition
myComponent.LocalPosition += new Vector3(0.5f, 0.0f, 0.0f);