Transform LocalTransform { get; set; }

book_4_sparkGenerated
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. If the game object has no parent, the local transform is relative to the scene's origin.

Usage

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

Example

// Example of setting a GameObject's local transform
GameObject myObject = new GameObject();
Transform newTransform = new Transform();
newTransform.Position = new Vector3(1, 2, 3);
newTransform.Rotation = Rotation.From(45, 0, 0);
newTransform.Scale = new Vector3(1, 1, 1);

myObject.LocalTransform = newTransform;

// Example of getting a GameObject's local transform
Transform currentTransform = myObject.LocalTransform;
Vector3 localPosition = currentTransform.Position;
Rotation localRotation = currentTransform.Rotation;
Vector3 localScale = currentTransform.Scale;