Adding custom collision to an object

Introduction - Why add custom collision?

Custom collision allows you to control where you can select 3D assets as well as where they block player movement.

Examples of Custom Collision

Walls: Make the walls and floors of a house have collision so the player cannot just walk through the walls.
U, L or O shaped objects: Allow the player to walk through a doorway for example
Animated objects: Add multiple collision volumes to a T-Rex's rig so you can select it in the Stage even if it moves around.

Preparing your objects in Blender

Collisions are added depending on the name of the object.
There are 4 types of collision:

  • -convcol: Convex collision will be added using the same geometry as the mesh.
  • -convcolonly: Convex collision will be added using the same geometry as the mesh and the visible mesh is removed.
  • -col: Concave collision will be added using the same geometry as the mesh
  • -colonly: Concave collision will be added using the same geometry as the mesh and the visible mesh is removed.

Always try to add Convex collision where possible. Convex collision is less intensive for calculations.
Convex means shapes without holes. The left shape is convex, the right shape is concave:

Example

You have an object called Obstacle. By adding -convcolat the end (it must be at the end!) collision will be added using the same mesh.
So the object is now called Obstacle-convcol.
That's all you have to do! Here's how it would look in Blender and the result:

 

So you could:

  • Use the visible mesh for collision too
  • Make a custom collision mesh and make it invisible in the Stage
  • Use a simple shape for collision (see below)

Collision shapes

You can add collision by using Blender's 'empty' shapes. These are more calculation efficient than mesh colliders.

Object TagDescriptionBlenderResult
-boxFor simple boxy shapes. You can scale the box to enclose the object you want to have collision.
-sphereFor simple spherical shapes. You can scale the sphere to enclose the object you want to have collision.
-capsuleA pill shaped collider, for more organic shapes.
Beware! The object needs to be scaled on it's Z-axis.

Example

You have an object called Obstacle-col. By adding -box before the end collision will be added using the box shape.
So the object is now called Obstacle-box-col.
You can scale the shape as needed so it fits.

Complex shapes

Sometimes we have more complex shapes, concave shapes with holes like this donut shape for example:

There's two solutions that help with these shapes:

  • Split it up in multiple convex parts
  • Mark it as non-convex

Interior environments

For interiors, the same idea applies as Complex shapes.
Here the floor, ceiling and the different sides of the wall have been split up. Which results in this:

Was this article helpful?