Description
The LocalPosition
property of a GameObject
represents its position relative to its parent object. If the GameObject
does not have a parent, the local position is relative to the scene's origin. This property is useful for positioning objects in a hierarchical structure, allowing for transformations that are relative to a parent object.
Usage
Use the LocalPosition
property to get or set the local position of a GameObject
. This property is of type Vector3
, which means it contains three components: X, Y, and Z, representing the position in 3D space.
To set the local position, assign a new Vector3
value to the property. To retrieve the current local position, simply access the property.
Example
// Example of setting the local position of a GameObject
GameObject myObject = new GameObject();
myObject.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);
// Example of getting the local position of a GameObject
Vector3 currentPosition = myObject.LocalPosition;
// Output the current local position
// Note: Use a logging system instead of Console.WriteLine
Log.Info($"Current Local Position: {currentPosition}");