Rotation WorldRotation { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The WorldRotation property represents the rotation of the game object in world space. This property provides the orientation of the game object relative to the global coordinate system, rather than its local coordinate system.

Usage

Use the WorldRotation property to get or set the rotation of a game object in the world space. This is useful when you need to align the game object with other objects or the world itself, independent of its parent objects.

Example

// Example of setting the WorldRotation of a component
Component myComponent = someGameObject.GetComponent<Component>();
myComponent.WorldRotation = Rotation.FromAxis(Vector3.Up, 45); // Rotates the object 45 degrees around the Up axis

// Example of getting the WorldRotation of a component
Rotation currentRotation = myComponent.WorldRotation;
Console.WriteLine($"Current World Rotation: {currentRotation}");