GameTransform Transform { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Transform property of a GameObject provides the position, rotation, and scale of the object relative to its parent. If the GameObject does not have a parent, the transform is relative to the scene.

Usage

Use the Transform property to access or modify the local transformation of a GameObject. This includes its position, rotation, and scale in relation to its parent object or the scene if it has no parent.

Example

// Example of accessing the Transform property
GameObject myObject = new GameObject();
GameTransform transform = myObject.Transform;

// Set position relative to parent or scene
transform.Position = new Vector3(10, 0, 5);

// Set rotation
transform.Rotation = Rotation.FromAxis(Vector3.Up, 45);

// Set scale
transform.Scale = new Vector3(1, 1, 1);