Rotation WorldRotation { get; set; }

robot_2Generated
code_blocksInput

Description

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

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 GameObject with a specific direction in the world or when you want to apply a rotation that is independent of the GameObject's parent.

Example

// Example of setting the WorldRotation 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 WorldRotation of a GameObject
Rotation currentRotation = myObject.WorldRotation;

// Adjusting the WorldRotation
myObject.WorldRotation *= Rotation.FromAxis(Vector3.Right, 45); // Further rotates the object 45 degrees around the right axis