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 position or scale.
Usage
To use the WithRotation
method, you need to pass a Rotation
reference as a 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 specified rotation
Transform updatedTransform = originalTransform.WithRotation(ref newRotation);
// The updatedTransform now has the new rotation, but retains the original position and scale.