Vector3 LocalPosition { get; set; }

robot_2Generated
code_blocksInput

Description

The LocalPosition property represents the local position of the game object within its parent. It is a Vector3 value that specifies the position relative to the parent object's origin. This property is useful for manipulating the position of a game object in a local context, without affecting its global position in the scene.

Usage

To get or set the local position of a game object, use the LocalPosition property. This property is part of the Component class, which means it can be accessed from any component attached to a game object.

Example usage:

var component = myGameObject.GetComponent<MyComponent>();
Vector3 currentLocalPosition = component.LocalPosition;
component.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);

Example

// Example of setting the local position of a game object
var myComponent = myGameObject.GetComponent<MyComponent>();

// Get the current local position
Vector3 currentLocalPosition = myComponent.LocalPosition;

// Set a new local position
myComponent.LocalPosition = new Vector3(1.0f, 2.0f, 3.0f);