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.
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.
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 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);