Rotation WorldRotation { get; set; }

robot_2Generated
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 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.0f); // Rotates the object 45 degrees around the up axis

// Example of getting the WorldRotation of a component
Rotation currentRotation = myComponent.WorldRotation;
Vector3 forwardDirection = currentRotation.Forward; // Get the forward direction based on the current rotation