Transform WithPosition( Vector3 position )
Transform WithPosition( Vector3 position, Rotation rotation )

book_4_sparkGenerated
code_blocksInput

Description

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

Usage

To use the WithPosition method, call it on an existing Transform instance and pass a Vector3 representing the new position. The method returns a new Transform instance with the updated position.

Example

// Example of using WithPosition method
Transform currentTransform = new Transform();
Vector3 newPosition = new Vector3(10, 20, 30);

// Create a new Transform with the updated position
Transform updatedTransform = currentTransform.WithPosition(newPosition);

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