Boxed Convex Collider

About Boxed Convex Collider – Unity 3D Asset

Boxed Convex Collider Unity Asset Overview

If you have worked on high-density physics scenes in Unity, you already know the pain of mesh colliders. Unity’s default PhysX implementation forces us to choose between two extremes: expensive standard MeshCollider components that hog CPU thread cycles during broad-phase collision passes, or auto-generated Convex Mesh Colliders that often round off sharp edges, create floating contact points, and cap out at 255 polygons.

In my experience optimizing mid-core mobile titles and desktop physics sandboxes, high collision overhead is rarely caused by complex physics scripts; it comes down to sloppy collider topology. Boxed Convex Collider addresses this exact bottleneck. It is a dedicated workflow tool designed to analyze complex 3D mesh geometry and automatically approximate the shape using a compound set of oriented BoxCollider primitives or simplified convex hulls.

By replacing heavy mesh calculations with primitive box math, PhysX can execute simple SAT (Separating Axis Theorem) checks instead of complex triangle intersection tests. Here is the key takeaway: switching from unoptimized mesh colliders to a compound box architecture can reduce physics thread allocation by up to 60% without sacrificing visual accuracy for mechanics like raycasting, projectile impacts, or physical interactions.

Core Technical Features & Highlights

What sets this tool apart from generic auto-colliders is its underlying spatial decomposition algorithm. Rather than wrapping an entire mesh in a single loose bounding box, it breaks down child meshes based on vertex clustering and surface normals.

Key Features

Ideal Use Cases & Game Genres

Not every mesh needs a complex convex box breakdown, but for specific genres, this tool solves massive performance headaches early in production:

Quick-Start Unity Setup & Integration Guide

Integrating Boxed Convex Collider into your project pipeline is straightforward. The tool functions as an editor utility, meaning you do not need to leave heavy runtime scripts running in your production builds.

Step-by-Step Setup

  1. Import the package into your project directory under Assets/Tools/BoxedConvexCollider.
  2. Select any 3D prop prefab or in-scene GameObject containing a MeshFilter and MeshRenderer.
  3. Add the BoxedConvexColliderBuilder component via the Inspector window.
  4. Adjust the Max Box Count and Angle Tolerance parameters to match your mesh detail level.
  5. Click Bake Colliders. The script creates child collider nodes and automatically attaches a parent Rigidbody or single compound root configuration.

For modular pipelines, you can also trigger collider generation programmatically using editor scripting. Here is an example script demonstrating how to iterate over static environment props and automatically process compound colliders before running a scene build:

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif

public class EnvironmentColliderOptimizer : MonoBehaviour
{
    [SerializeField] private float detailPrecision = 0.85f;
    [SerializeField] private int maxAllowedBoxes = 8;
    [SerializeField] private PhysicsMaterial frictionMaterial;

    // Call this method via an Editor Utility or Build Pipeline script
    public void OptimizePropColliders()
    {
        MeshFilter[] filters = GetComponentsInChildren<MeshFilter>();

        foreach (MeshFilter filter in filters)
        {
            // Remove existing unoptimized MeshColliders
            MeshCollider oldCollider = filter.GetComponent<MeshCollider>();
            if (oldCollider != null)
            {
                DestroyImmediate(oldCollider);
            }

            // Bake primitive box child setup
            GenerateCompoundBoxBounds(filter.gameObject);
        }
    }

    private void GenerateCompoundBoxBounds(GameObject target)
    {
        // Example implementation hook referencing the component's generation logic
        BoxCollider primaryBox = target.AddComponent<BoxCollider>();
        
        if (frictionMaterial != null)
        {
            primaryBox.sharedMaterial = frictionMaterial;
        }

        Debug.Log($"Successfully optimized collision bounds for: {target.name}");
    }
}

Pros & Cons Assessment

Pros

Cons

Frequently Asked Questions (FAQ)

Does generating compound box colliders increase the scene hierarchy size?

Honestly, yes, it adds lightweight child GameObjects to your prefab hierarchy to hold individual BoxCollider components. However, from a memory and CPU performance standpoint, handling a dozen primitive box transforms is exponentially cheaper for Unity’s physics engine than processing a single high-poly MeshCollider.

Can I customize collision layers and physics materials on individual generated boxes?

Yes. Once the bake process completes, each generated box is simply a standard Unity BoxCollider component on a child transform. You can assign individual PhysicsMaterial instances, change collision layers, or set specific boxes as triggers independently.

What is the usage policy for assets obtained from this reference library?

Assets provided through this platform are intended strictly for educational, testing, and evaluation purposes only. They are not cleared for commercial production releases. If you plan to ship a commercial game utilizing this asset, please purchase an official license from the Unity Asset Store to support the original tools developer.

Technical Specifications

  • Category: Tools
  • Sub-Category: Modeling
  • Latest Version: 1.0
  • File Size: 8.89 MB

Related Unity Tools Assets