Tree colliders in Unity
Part of LODs and billboards for low poly models
A tree collides with the player at its trunk and nowhere else. The canopy is something you walk under, a branch is something you walk past, and a collider that follows the foliage traps the player in a green box. This is the setup, for a tree placed by hand and one painted on terrain. The collider sits on the same prefab as the LOD Group and the billboard, all of them part of levels of detail for low poly models, and the importer setting that adds the wrong collider is on the tab the Unity import article walks through.
The wrong collider
Unity's model importer has a Generate Colliders checkbox that adds a Mesh Collider to every mesh in the file. For a prop, that is often right. For a tree, it wraps the foliage: the player cannot walk under the boughs, cannot stand near the trunk, and the physics engine spends time on hundreds of triangles per tree that do nothing useful. Leave it off for trees.
The right one
A Capsule Collider on the trunk:
- Select the tree's root GameObject, or its prefab.
- Add Component, Capsule Collider.
- Set Direction to Y-Axis, Radius to the trunk's radius at chest height, Height to the trunk's height up to the first bough, and Center to half that height so the capsule stands on the ground.
The capsule stops the player walking through the trunk and lets them walk under everything else. It is also what Unity's own terrain trees use, and what every game does. For a tree with a wide base or a leaning trunk, a second capsule or a cylinder-ish mesh collider on the trunk mesh alone; never on the foliage.
For a low poly tree whose trunk and foliage are one mesh, which is how a palette-textured export comes, the capsule is the only sane option anyway, because a mesh collider would have to include the foliage.
The felled trunk, the stump and the logs
A fallen tree is a capsule lying down, Direction Z-Axis, or a Box Collider the length of the trunk. A stump is a short capsule or a cylinder. Logs are small capsules, and if the player is to pick them up, a Rigidbody as well, with the capsule giving stable physics where a mesh collider would jitter.
Terrain trees
Trees painted onto a Unity Terrain take their collider from the prefab: if the prefab has a Capsule Collider, the terrain uses it; if it has none, there is no collision. The terrain's own Tree Collider handling supports capsule colliders only, which is another reason to use one. Give the prefab the capsule before painting.
Layers and cost
Put trees on their own physics layer if the project has many, so raycasts for other things can skip them. A capsule is the cheapest shape after a sphere; a thousand of them cost nothing.
The same elsewhere
- Godot: a CollisionShape3D with a CapsuleShape3D, under a StaticBody3D that is a sibling of the mesh; the Mesh menu's Create Trimesh Collision is the wrong tool for a tree for the same reason.
- Unreal: in the Static Mesh editor, Collision menu, Add Capsule Simplified Collision, then size it to the trunk; turn off Auto Generate Collision on import.
What PolyMason exports
The tree builder writes the trunk's height and diameter in the zip's spec, so the capsule's numbers are there to read. The model stands on the ground at the origin, so the capsule's centre is half the trunk height up and nothing else.
More in this guide
- LODs and billboards for low poly modelsHow levels of detail work, what triangle counts are reasonable for low poly trees, rocks and buildings, how to make the levels so the swap does not pop, billboards and impostors for the far distance, and the LOD setup in Unity, Godot and Unreal.
- Unity's LOD Group, set up from separate model filesHow to build a LOD Group in Unity from three separate model files, what the screen-height thresholds mean, the naming convention that makes the importer build the group for you, fade modes, LOD Bias, and how LOD Groups get on with batching and instancing.
- Billboard trees in Unity: the far level of detailWhat a tree billboard is, how to make the picture, the two ways to show one in Unity, a quad with a cutout material or a Billboard Renderer, how terrain trees do it for you, and the settings that keep it from looking flat.
- Levels of detail in Godot 4: automatic mesh LODs and visibility rangesThe two LOD systems in Godot 4, the automatic mesh LODs the importer generates and the visibility ranges you set on nodes, how to control each, fading between levels, and how they work with MultiMesh for a forest.
Or build a tree and see what comes out.