TransformUtils

This class provides additional functionality for working with Transform.

Available Methods


public static float Distance(this Transform from, Transform to)

This method returns distance between two transforms.


public static float DistanceXZ(this Transform from, Transform to)

This method returns 2D distance between two given 3D transforms (in XZ plane, ignoring Y).

This method could be useful for getting distance between characters in top-down or strategy games, ignoring height of that characters.


public static void MoveTowards(this Transform t, Transform target, float speed)

This method moves transform towards certain transform with given speed.


public static void ResetTransform(this Transform t)

This method resets position, rotation and scale of given transform.


public static void LookAtIgnoreY(this Transform t, Transform target)

This method faces transform to the given transform, ignoring Y axis. It could be useful for top-down games.

Example:


This method searches a child Transform by its name even if this child is deeply nested.

Example:


This method sets the same scale for all axes.

Example:


This method checks if given transform visible for certain camera.

Example:


This method destroys all nested children of given transform.

Example:

Last updated