For performance, and by default, we often use other primitive shape colliders, such as Sphere, Box, and Cylinder to approximate the shape of a collision mesh. In this tutorial, we create a MeshCollider for a terrain geometry. When you want to use a mesh as a terrain geometry, your Rigid Body component will be on the entities that collide with the mesh.
Note: At the time of this writing, the Collider component’s Shape options don’t include the MeshCollider collider type. Therefore, the only way to create a MeshCollider shape is by using code in a Script component.
This is the scene we will build in this tutorial. For best results, be sure you are using the latest version of your browser.
Before you begin, complete the following tasks and tutorials:
- Sign in to Amazon Sumerian with your AWS account
- All Sumerian Beginner tutorials
- Review State Machine basics tutorial
- Review Scripting basics tutorial
- MeshCollider on a Torus tutorial
- Download this terrain .fbx file
Step 1: Add Terrain
Create a new scene using the Default Lighting scene template.
Drag the mesh terrain object, mountain.fbx, which you already downloaded (see Prerequisites) onto the canvas to upload it to your scene.
Navigate to the Assets panel, and then drag the mountain entity onto the canvas.
You now see the mountain entity, which is the terrain, in your scene.
Note: You might want to reduce the Intensity of the Directional lights. You can access these lights in your Default Lights parent entity.
Step 2: Add a MeshCollider
This step to add a MeshCollider follows a process similar to the one in the MeshCollider Torus tutorial.
Expand the parent mountain entity until you can see its child pPlane1_lambert1 entity.
We want to add a MeshCollider onto this entity because this entity carries the Geometry component.