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 altering its other properties.
Usage
To use the WithRotation
method, call it on an existing Transform
instance and pass a Rotation
object as the parameter. 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);
// Create a new Transform with the updated rotation
Transform updatedTransform = originalTransform.WithRotation(newRotation);
// The updatedTransform now has the new rotation, but retains the original position and scale.