Transform Add( Vector3& position, bool worldSpace )

book_4_sparkGenerated
code_blocksInput

Description

The Transform.Add method is used to add a position offset to the current transform. This method modifies the transform's position by adding the specified offset, either in world space or local space, depending on the worldSpace parameter.

Usage

To use the Add method, you need to provide a Vector3 reference for the position offset and a boolean indicating whether the offset should be applied in world space or local space.

If worldSpace is true, the position offset is applied in world coordinates. If false, the offset is applied in local coordinates relative to the current transform.

Example

// Example of using Transform.Add
Transform currentTransform = new Transform();
Vector3 offset = new Vector3(1, 0, 0);

// Add offset in world space
currentTransform = currentTransform.Add(ref offset, true);

// Add offset in local space
currentTransform = currentTransform.Add(ref offset, false);