Rotation WorldRotation { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The WorldRotation property of a GameObject represents the rotation of the object in the world space. This property provides the orientation of the object relative to the global coordinate system, rather than its local coordinate system or its parent's coordinate system.

Usage

Use the WorldRotation property to get or set the rotation of a GameObject in world space. This is useful when you need to align the object with a specific direction in the world or when you want to apply transformations that are independent of the object's parent.

Example

// Example of setting the world rotation of a GameObject
GameObject myObject = new GameObject();
myObject.WorldRotation = Rotation.FromAxis(Vector3.Up, 90); // Rotates the object 90 degrees around the up axis

// Example of getting the world rotation of a GameObject
Rotation currentRotation = myObject.WorldRotation;
Console.WriteLine($"Current World Rotation: {currentRotation}");