Vector3 LocalPosition { get; set; }

robot_2Generated
code_blocksInput

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

To get or set the local position of a GameObject, you can 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.

When setting the LocalPosition, ensure that the new position is a valid Vector3 value. Changing the local position will affect the GameObject's position relative to its parent, but not its global position unless the parent is also moved or transformed.

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 position = myObject.LocalPosition;

// Output the local position
// Note: Use a logging system instead of Console.WriteLine
Log.Info($"Local Position: {position}");