hammerBuilding a Basic Game

To get you started, this guide walks you through building an apple collection game!

Apple Collection

circle-info

This example game skims over details that are covered in-depth in other guides. If you need any help, check the left sidebar or use the search feature at the top for extra information!

Building the map

We'll start by creating a basic world with an island to walk on and an apple to collect later!

  1. Search for an Apple and an Island in the Asset Catalog and drag them into your game's scene view.

  1. That island is pretty small! In the Inspector set the Scale to 10x10 to make it bigger

  1. Now the island is a good size, but the apple is behind the island! Set the island's Layer to -10 to push it behind everything else.

Adding Scripts

In your game project's scripts directory, create a new file called pickup_apple.csl and open it in a text editor or use an AI based IDE.

Paste the following example script and save the file:

Adding the Apple component

Now that you've created your apple script, we'll need to apply it to the apple in the scene. To do that, we'll add the new Pickup_Apple component from the script by using the Inspector.

  1. Select your Apple in the scene

  2. Click the "Add Component" button in the Inspector.

  3. Search for the "Pickup_Apple" component and click it to add it to the apple

Now you'll see the component has been added to the apple! You can adjust some fields from the Apple by changing the values in the inspector:

Playing your game

When you're ready, hit the fun green triangle and try your game!

Next Steps

In the next sections, you'll learn how to playtest your game with multiple players, create your own scripts, and build your dream world.

Here are some challenges to try:

  • Make many apples for the player to eat

  • Play sound effects when eaten

  • Advanced: try writing a script to respawn more apples after they're eaten

--

circle-info

SIDE NOTE: If your island is low resolution/pixelated, click the island's png asset in the "Assets" section and set the Resample Multiplier to 1 and click Apply

Last updated