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

MeshUtils

PreviousTransformUtilsNextUseful Components

Last updated 4 months ago

This class provides useful helper methods for 3D meshes. For example, you can easily slice your mesh into 2 parts!

Available methods

public static GameObject[] Slice(GameObject origin, Vector3 cutOrigin, Vector3 cutNormal)

This method slices given mesh into 2 parts, saving all physical characteristics and collider (if was presented on original gameobject).

cutOrigin is point where slice plane should pass (in local object's space, so Vector3.zero will be the center of object).

Example:

//Slice myself into 2 equal parts, vertically
MeshUtils.Slice(gameObject, Vector3.zero, Vector3.right);

public static GameObject[] Fracture(GameObject origin, int fragmentsCount, FractureMode fractureMode)

This method fractures given object into certain count of fragments, with certain fracture mode.

Example:

//Fracture gameobject into 6 fragments with different angles of slicing
MeshUtils.Fracture(gameObject, 6, FractureMode.RandomAngles);

public static bool GetPlaneIntersectionPoint(Vector3 from, Vector3 to, Vector3 planeOrigin, Vector3 normal, out Vector3 result)

This method finds intersection point between given vector (set by from and to positions) and plane.

Example:

if (MeshUtils.GetPlaneIntersectionPoint(startPoint, 
    endPoint, planePos, planeNormal, out var foundPoint))
{
    Debug.Log($"Intersection found: {foundPoint}");
}
Mesh was sliced into 2 parts
Mesh was fractured into 6 fragments