Build the level
Create the project
- In the Project Hub, select New Project..., enter
CoinCollectoras the Name and select Create. - Open
CMakeLists.txtin the project folder and add these lines at the end:
# the packages this game calls into: physics for the player and the coins,
# audio for the pickup sound
target_link_libraries(CoinCollector PRIVATE Shalltear::Physics3D Shalltear::Audio)The game uses two of the engine's packages: Physics 3D moves the player and notices the coins, and Audio plays the pickup sound. A new project has both turned on, but your code can call a package only once CMakeLists.txt links it. The editor compiles again when you save the file.
A scene for the first level
- Select File ▸ New Scene. The new scene has a camera and a light.
- Press Ctrl+S. The scene has never been saved, so the editor asks for a path. Change
UntitledtoLevel1so it readsproject://Assets/Scenes/Level1.scene, and select OK.
The floor and the walls
- In the Hierarchy, select + and choose 3D Object ▸ Cube. Press F2 and rename it
Floor. - In the Inspector, set Position to
0, -0.5, 0and Scale to20, 1, 20. - Select Add Component, type
BoxColliderand select it. A collider gives an object a shape that physics can collide with, and a box collider fits a cube of any scale. - Make the four walls the same way. Each is a Cube with a BoxCollider. Select a wall and press Ctrl+D to duplicate it rather than start again.
| Name | Position | Scale |
|---|---|---|
Wall North | 0, 1, 10.5 | 22, 2, 1 |
Wall South | 0, 1, -10.5 | 22, 2, 1 |
Wall East | 10.5, 1, 0 | 1, 2, 20 |
Wall West | -10.5, 1, 0 | 1, 2, 20 |
Colors
- In the Asset Browser, select + and choose Create ▸ Material. Press F2, rename it
Ground.matand select OK. - In the Inspector, set baseColor to a gray and select Save.
- Select the floor, and drag
Ground.matfrom the Asset Browser onto Material 0 in its MeshRenderer. Do the same for each wall. - Make two more materials the same way for the next pages:
Gold.matin yellow andPlayer.matin blue.
The camera
Select Main Camera and set Position to 0, 16, -14 and Rotation to 50, 0, 0. It now looks down at the arena from one end. The Runtime View shows what it sees.
Press Ctrl+S to save. Next, make a coin.