Transform

csharp
public class Transform : Component

Namespace NodeWorld.Flux.

The position, rotation, scale and parent of an object, as Unity's Transform.

Properties

position

csharp
public Vector3 position { get; set; }

Position in the world.

rotation

csharp
public Quaternion rotation { get; set; }

Rotation in the world.

localPosition

csharp
public Vector3 localPosition { get; set; }

Position in the parent's space.

localRotation

csharp
public Quaternion localRotation { get; set; }

Rotation in the parent's space.

localScale

csharp
public Vector3 localScale { get; set; }

Scale in the parent's space.

lossyScale

csharp
public Vector3 lossyScale { get; }

Scale in the world (read only).

eulerAngles

csharp
public Vector3 eulerAngles { get; set; }

Rotation in the world, as angles in degrees.

localEulerAngles

csharp
public Vector3 localEulerAngles { get; set; }

Rotation in the parent's space, as angles in degrees.

forward

csharp
public Vector3 forward { get; set; }

The object's blue axis (z) in the world; setting it turns the object to face that way.

up

csharp
public Vector3 up { get; }

The object's green axis (y) in the world.

csharp
public Vector3 right { get; }

The object's red axis (x) in the world.

localToWorldMatrix

csharp
public Matrix4x4 localToWorldMatrix { get; }

The matrix from the object's space to the world.

worldToLocalMatrix

csharp
public Matrix4x4 worldToLocalMatrix { get; }

The matrix from the world to the object's space.

parent

csharp
public Transform parent { get; set; }

The parent transform (null: a root of the scene). Setting it keeps the object where it is in the world.

childCount

csharp
public int childCount { get; }

The number of children.

root

csharp
public Transform root { get; }

The topmost parent (the transform itself when it has none).

Methods

GetChild

csharp
public Transform GetChild(int index)

The child at index, 0 to childCount - 1.

Find

csharp
public Transform Find(string path)

The child at this path below this transform ("Child/Grandchild"), or null.

SetParent

csharp
public void SetParent(Transform parent)

Sets the parent, as the parent property: the object stays where it is in the world.

GetSiblingIndex

csharp
public int GetSiblingIndex()

The object's place among its parent's children.

SetSiblingIndex

csharp
public void SetSiblingIndex(int index)

Moves the object to that place among its parent's children.

SetAsLastSibling

csharp
public void SetAsLastSibling()

Moves the object last among its parent's children.

SetAsFirstSibling

csharp
public void SetAsFirstSibling()

Moves the object first among its parent's children.

IsChildOf

csharp
public bool IsChildOf(Transform parent)

This transform is parent, or below it.

SetPositionAndRotation

csharp
public void SetPositionAndRotation(Vector3 position, Quaternion rotation)

Sets the position and the rotation in the world.

TransformPoint

csharp
public Vector3 TransformPoint(Vector3 position)

A point from the object's space to the world (position, rotation and scale).

InverseTransformPoint

csharp
public Vector3 InverseTransformPoint(Vector3 position)

A point from the world to the object's space.

TransformDirection

csharp
public Vector3 TransformDirection(Vector3 direction)

A direction from the object's space to the world (rotation only).

InverseTransformDirection

csharp
public Vector3 InverseTransformDirection(Vector3 direction)

A direction from the world to the object's space (rotation only).

TransformVector

csharp
public Vector3 TransformVector(Vector3 vector)

A vector from the object's space to the world (rotation and scale).

InverseTransformVector

csharp
public Vector3 InverseTransformVector(Vector3 vector)

A vector from the world to the object's space (rotation and scale).

Translate

csharp
public void Translate(Vector3 translation, Space relativeTo = Space.Self)

Moves the object by translation, along its own axes (Space.Self) or the world's.

Rotate

csharp
public void Rotate(Vector3 eulers, Space relativeTo = Space.Self)

Turns the object by these angles in degrees, around its own axes (Space.Self) or the world's.

csharp
public void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self)

Turns the object by angle degrees around axis (in its own space with Space.Self).

LookAt

csharp
public void LookAt(Vector3 worldPosition, Vector3 worldUp)

Turns the object so that its forward points at worldPosition and its up toward worldUp.

csharp
public void LookAt(Vector3 worldPosition)

Turns the object so that its forward points at worldPosition, its up toward the world's up.

csharp
public void LookAt(Transform target)

Turns the object so that its forward points at target.