Heroic Engine
  • Welcome
  • Getting Started
    • Quickstart
    • Example Games
      • Tic Tac Toe
      • Turn based duel
  • Basics
    • Injection Manager
    • Engine Systems
      • Core Systems
        • Events Manager
        • Input Manager
        • Localization Manager
          • LangText component
        • Music Player
        • Sounds Manager
        • Time Manager
        • Scenes Loader
        • Day Time Controller
        • Weather Controller
      • Gameplay Systems
        • Currencies Manager
        • Player Progression Manager
        • Quest Manager
        • Random Events Manager
        • Hittables Manager
        • Dungeon Generator
      • UI Systems
        • UI Controller
        • Countdown Controller
    • Editor Tools
      • Clear Saves
      • Mobile Build Optimizer
      • Create System
      • Icon from Prefab Generator
    • Engine Utilities
      • PoolSystem
      • DataSaver
      • ComponentExtensions
      • MaterialExtensions
      • SpriteUtils
      • SlowUpdate
      • StringUtils
      • TypeUtility
      • MathHelper
      • VectorUtils
      • TransformUtils
      • MeshUtils
    • Useful Components
      • Floating Item
      • Fly Up Text
      • Label Scaler
      • Ragdoll
      • Rotate To Camera
      • Orbital Camera
      • Rotator
      • Texture Mover
      • Hittable
      • Projectile
      • Projectile2D
      • LifetimeObject
      • Spawner
      • Colorized Particles
      • Draggable2D
      • SaveableTransform
    • Useful Attributes
Powered by GitBook
On this page
  1. Basics
  2. Engine Utilities

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:

turretTransform.LookAtIgnoreY(enemyTransform);

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:

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

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

This method sets the same scale for all axes.

Example:

transform.SetUniformScale(2f);

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

This method checks if given transform visible for certain camera.

Example:

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

public static void DestroyAllChildren(this Transform t)

This method destroys all nested children of given transform.

Example:

rewardsTransform.DestroyAllChildren(); //Clear rewards UI slots
PreviousVectorUtilsNextMeshUtils

Last updated 3 months ago