meshfx // COLLISION // GODOT
How to add a collision mesh in Godot 4
In Godot 4 you add collision to a mesh by selecting the MeshInstance3D, opening the Mesh menu at the top of the 3D viewport and choosing Create Collision Shape, which builds a trimesh or convex shape. For imported models, add a -col or -colonly suffix to a mesh's name in your 3D editor and Godot builds the collision on import.
pyrofx effects work today, and new accounts start with $5 of usage.
meshfx measures faults, checks repairs and makes LODs for a triangle budget. meshfx runs on the hosted API: try it in the Playground.
- Mesh > Create Collision Shape
- Suffixes: -col, -convcol, -colonly
- Trimesh for static, convex for moving
01 // IN THE EDITOR
Create a collision shape from a mesh
- Select the
MeshInstance3Din the scene tree. - Click Mesh in the 3D viewport toolbar and choose Create Collision Shape.
- Pick the placement: a sibling
CollisionShape3Dwhen the mesh already sits under a physics body, or a newStaticBody3Dchild. - Pick the type: Trimesh for static level geometry, Single Convex or Simplified Convex for a prop that moves, Multiple Convex for a concave prop that moves.
- Turn on Debug > Visible Collision Shapes and run the scene to check the result.
02 // ON IMPORT
Build collision on import with name suffixes
-colkeeps the mesh and adds aStaticBody3Dwith a trimesh shape made from it.-convcoldoes the same with a convex shape.-colonlyremoves the mesh and keeps only the collision, for a separate simple mesh you modeled for physics.-convcolonlykeeps only a convex collision shape.
A common setup is a detailed Rock mesh plus a 50-triangle Rock-colonly mesh in the same file. Advanced Import Settings also has a Physics section for each mesh node, where you can generate a body and pick a shape type (Decompose Convex, Simple Convex, Trimesh, Box, Sphere, Cylinder or Capsule) without renaming anything.
03 // WHICH SHAPE
Trimesh or convex
A trimesh shape (ConcavePolygonShape3D) follows every triangle, so it fits level geometry exactly, but it is meant for static bodies and costs more to test against. A convex shape (ConvexPolygonShape3D) wraps the mesh with no dents, which makes it fast and safe for bodies that move. For a concave prop that moves, such as a chair, combine a few convex shapes or primitive boxes.
For meshes you load or generate at runtime, build the collision from code.
extends Node3D
@onready var rock: MeshInstance3D = $Rock
func _ready() -> void:
# Adds a StaticBody3D child with a convex shape built from the mesh.
rock.create_convex_collision()
04 // meshfx
meshfx for collision in godot 4
meshfx measures faults, checks repairs and makes LODs. Build physics shapes in your engine or editor. Hosted meshfx runs are available in the Playground.
How do I give a mesh collision in Godot?
Select the MeshInstance3D, open the Mesh menu in the 3D viewport and choose Create Collision Shape for a trimesh or convex shape.
How do I import a collision mesh into Godot?
Add the Godot collision only suffix to your collision mesh name before exporting glTF so Godot creates a StaticBody3D without rendering it.
How do I make a collision mesh in a 3D editor for Godot?
Model a simple low poly wrapper around your object, name it with the Godot collision suffix and export both in one glTF.
Why is collision not working in Godot?
Verify the CollisionShape3D sits under a physics body, shares collision layers and masks and uses convex shapes for moving RigidBody3D nodes.
Should I use primitive shapes, convex hulls or a custom collision mesh in Godot?
Use primitive boxes or capsules first, convex shapes for moving irregular props and trimesh shapes only for static level geometry.
Explore meshfx outputs
Inspect compiled meshfx outputs and their reports. Hosted meshfx runs are available in the Playground.