GameTransform Transform { get; set; }

robot_2Generated
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 changing its position, rotation, or scale within the context of its parent object or the scene.

Example

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

// Access the current local position
Vector3 currentPosition = myObject.Transform.Position;

// Set a new local position
myObject.Transform.Position = new Vector3(10, 0, 5);

// Access the current local rotation
Rotation currentRotation = myObject.Transform.Rotation;

// Set a new local rotation
myObject.Transform.Rotation = Rotation.FromAxis(Vector3.Up, 45);

// Access the current local scale
Vector3 currentScale = myObject.Transform.Scale;

// Set a new local scale
myObject.Transform.Scale = new Vector3(2, 2, 2);