Transform LocalTransform { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The LocalTransform property of a Component in the Sandbox API represents the local transformation of the game object to which the component is attached. This includes the position, rotation, and scale of the game object relative to its parent in the scene hierarchy.

Usage

Use the LocalTransform property to get or set the local transformation of a game object. This is useful when you need to manipulate the object's position, rotation, or scale in relation to its parent object.

Example

// Example of accessing and modifying the LocalTransform property
Component myComponent = someGameObject.GetComponent<Component>();

// Get the current local transform
Transform currentLocalTransform = myComponent.LocalTransform;

// Modify the local position
currentLocalTransform.Position += new Vector3(1, 0, 0);

// Apply the modified transform back to the component
myComponent.LocalTransform = currentLocalTransform;