# TransformUtils

This class provides additional functionality for working with Transform.

### Available Methods

***

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

*This method returns distance between two transforms.*

***

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

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

{% hint style="info" %}
This method could be useful for getting distance between characters in top-down or strategy games, ignoring height of that characters.
{% endhint %}

***

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

*This method moves transform towards certain transform with given speed.*

***

```csharp
public static void ResetTransform(this Transform t)
```

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

***

```csharp
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:*

```csharp
turretTransform.LookAtIgnoreY(enemyTransform);
```

***

```csharp
public static Transform FindDeepChild(this Transform parent, string name)
```

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

*Example:*

```csharp
var chairTransform = houseTransform.FindDeepChild("Chair");
```

***

```csharp
public static void SetUniformScale(this Transform t, float scale)
```

*This method sets the same scale for all axes.*

*Example:*

```csharp
transform.SetUniformScale(2f);
```

***

```csharp
public static bool IsVisibleFrom(this Transform t, Camera camera)
```

*This method checks if given transform visible for certain camera.*

*Example:*

```csharp
if (transform.IsVisibleFrom(Camera.main))
{
    //Do some logics if this transform is visible from main camera...
}
```

***

```csharp
public static void DestroyAllChildren(this Transform t)
```

*This method destroys all nested children of given transform.*

*Example:*

```csharp
rewardsTransform.DestroyAllChildren(); //Clear rewards UI slots
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://heroicsolo.gitbook.io/heroic-engine/basics/engine-utilities/transformutils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
