Rotation LocalRotation { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The LocalRotation property of a GameObject represents the rotation of the object relative to its parent. This property is crucial for determining the orientation of the object within its local coordinate space, which is particularly useful when the object is part of a hierarchy of objects.

Usage

To access or modify the local rotation of a GameObject, you can use the LocalRotation property. This property is of type Rotation, which allows you to set or get the rotation in terms of quaternion values.

For example, if you want to rotate a GameObject by 90 degrees around the Y-axis, you can set the LocalRotation property accordingly.

Example

// Example of setting the local rotation of a GameObject
GameObject myObject = new GameObject();
myObject.LocalRotation = Rotation.FromAxis(Vector3.Up, 90); // Rotates the object 90 degrees around the Y-axis

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