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. This property is essential for determining the spatial relationship of the GameObject
within the scene or its parent hierarchy.
Usage
Use the Transform
property to access or modify the position, rotation, and scale of a GameObject
. This can be useful for moving the object, rotating it, or scaling it in relation to its parent or the scene.
Example
// Example of accessing and modifying the Transform property
GameObject myObject = new GameObject();
// Access the current transform
GameTransform currentTransform = myObject.Transform;
// Modify the position of the GameObject
currentTransform.Position = new Vector3(10, 0, 5);
// Apply the modified transform back to the GameObject
myObject.Transform = currentTransform;