Vector3 LocalPosition { get; set; }

robot_2Generated
code_blocksInput

Description

The LocalPosition property of a GameObject represents the position of the object relative to its parent. If the object has no parent, this position is relative to the scene's origin. This property is useful for manipulating the object's position within its local coordinate space, allowing for transformations that are independent of the world or parent transformations.

Usage

Use the LocalPosition property to get or set the local position of a GameObject. This can be useful when you want to move an object relative to its parent or when you need to perform operations that require knowledge of the object's local position.

Example

// Example of setting a GameObject's local position
GameObject myObject = new GameObject();
myObject.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);

// Example of getting a GameObject's local position
Vector3 localPos = myObject.LocalPosition;

// Output the local position
// Note: Avoid using Console.WriteLine in Sandbox
// Instead, use a debug tool or log system provided by the engine
DebugOverlay.Text(localPos.ToString(), myObject.WorldPosition);