This page will go into Colliders and how to best use them in your space
Colliders video Tutorial
Colliders are used in unity as the tools to make sure the player doesn't run or fall through your environment. Colliders are also used for other functionality, such as what the user can 'see' as the Canvas, Artifact, or Portal.
There are 4 main types of Collider in Unity :
- Box Collider
- Sphere Collider
- Capsule Collider
- Mesh Collider
There are others but these are the ones most commonly used on the Mona platform.
Applying a collider is as simple as adding the component to your object and modifying it as you need in order to cover the area you require. You can type in the type to find it faster (box, sphere, capsule, or mesh) or 'collider'. It is also possible to add a collider to an empty game object, this may be useful if you want to create an object that has all the wall colliders in one place.
Adding a box collider to the Cube
These colliders are the most common as they are the most performant. Use Box Colliders where you can as this doesn't cost nearly as much on performance as things like a mesh collider.
Box, Sphere, and Capsule Collider examples.
A mesh collider allows your to create custom meshes as the collider. These are not nearly as performant as the basic Colliders and should be used sparingly.
DO NOT put a Mesh collider on a high polygon object.
Using a Mesh collider on a high polygon object will slow down the space considerably. If you have to use a mesh collider for an asset in your space, then you should create an optimised mesh to be used for the collider. Design the optimised mesh with the basic shape in mind, and cut down the polygons as much as possible.
High polygon and low polygon examples
It is possible to make stairs work more like a ramp shown in the example above. Not only does this improve performance, but makes a smoother user experience as well especially for larger step heights.
Make sure that the position of the object and mesh collider line up in the Asset creation tool (such as Blender or Maya). This is not compulsory, but it makes lining things up much easier. The example image above with separated objects is not how they objects should be laid out.
To add a custom object as a mesh collider, make sure to use the child mesh object on the imported model. It should have a grid icon next to it. The Model itself cannot be used in the mesh collider slot.
Adding the Mesh of the Model to the Mesh collider
Mona uses Colliders in a variety of ways for different asset types.
Portals require a box collider (a mesh collider also works but is not recommended) on the 'Portal' tagged object in order to function correctly in Mona. This is used so that the user can 'see' the portal, and therefore interact with it.
Make sure that there are no colliders in front of the Portal tagged object Collider. If there is a collider in front of it, the user may not be able to see it, making the portal only work as an entrance to the space.
Objects tagged with 'Canvas' must have a mesh collider applied. No other collider works in this case.
Objects tagged with 'Artifact' can have a Box Collider (recommended) or mesh collider applied.
Make sure that there are no other colliders in front of the Artifact or Canvas tagged object Collider. If there is a collider in front of it, the user may not be able to see it, or interact with it.