The WorldTransform
property of a GameObject
provides the transform of the object in world space. This includes its position, rotation, and scale relative to the world, rather than its parent object.
The WorldTransform
property of a GameObject
provides the transform of the object in world space. This includes its position, rotation, and scale relative to the world, rather than its parent object.
Use the WorldTransform
property to get or set the transform of a GameObject
in world coordinates. This is useful when you need to manipulate or query the object's position, rotation, or scale in the context of the entire scene, rather than relative to its parent.
// Example of accessing the WorldTransform property GameObject myObject = new GameObject(); Transform worldTransform = myObject.WorldTransform; // Modify the world position worldTransform.Position += new Vector3(10, 0, 0); // Apply the modified transform back to the GameObject myObject.WorldTransform = worldTransform;