Transform WithRotation( Rotation& rotation )

book_4_sparkGenerated
code_blocksInput

Description

The WithRotation method of the Transform struct allows you to create a new Transform instance with a specified rotation while maintaining the original position and scale. This method is useful when you want to modify the rotation of a transform without affecting its other properties.

Usage

To use the WithRotation method, you need to pass a Rotation object by reference. The method returns a new Transform instance with the updated rotation.

Example

// Example of using WithRotation method
Transform originalTransform = new Transform();
Rotation newRotation = Rotation.FromAxis(Vector3.Up, 90);
Transform updatedTransform = originalTransform.WithRotation(ref newRotation);

// The updatedTransform now has the new rotation, but retains the original position and scale.