Transform LocalTransform { get; set; }

robot_2Generated
code_blocksInput

Description

The LocalTransform property of a GameObject represents the local transformation matrix of the game object. This matrix defines the position, rotation, and scale of the game object relative to its parent. It is a crucial property for determining how the game object is positioned and oriented in the scene, especially when it is part of a hierarchy of objects.

Usage

Use the LocalTransform property to get or set the local transformation of a GameObject. This can be useful when you need to manipulate the game object's position, rotation, or scale relative to its parent. Modifying the LocalTransform will affect how the game object is rendered in the scene.

Example

// Example of accessing and modifying the LocalTransform property
GameObject myObject = new GameObject();

// Get the current local transform
Transform currentTransform = myObject.LocalTransform;

// Modify the local transform
currentTransform.Position += new Vector3(1, 0, 0); // Move the object 1 unit on the X axis
currentTransform.Rotation *= Rotation.FromAxis(Vector3.Up, 45); // Rotate the object 45 degrees around the Y axis

// Apply the modified transform back to the GameObject
myObject.LocalTransform = currentTransform;