Description
Before we start read a brief tutorial on how to work with projects. After that download the initial template to your computer and follow the instructions from Getting started section to start working on a project.
Let's start creating our project by adding some objects to the Level 1 scene.
Add a background object as a camera child so that it follows the camera. Add the player and the end of the level objects. Add a ground with a Tilemap class to achieve a more pleasing visual experience. Here is a great tutorial video by Brackeys to get to know Tilemaps. There is an already sliced tileset asset in Assets/ForStages/Sprites folder. To prevent the character from falling into the abyss of the game space, add a collider to the Ground object. If needed, change the collider to fit the size of the area with the drawn cells
Also, add the Rigidbody2D component to a player object, and the Collider2D components for objects. Freeze Rigidbody2D's constraints by rotation and unfreeze by position, set it's interpolation property to Interpolate. Don't forget to properly sort the objects, so that sprites will be shown in the correct order. To learn how to sort, you can refer to the Renderer.sortingOrder part of the official docs.
Objectives
Name the scene as
Level 1;Add the following objects to the scene. Object names are indicated in the parentheses; their hierarchy is shown as a list:
1. Camera (Main Camera)
1.1. Background (Background)
2. Character (Player)
3. Grid for tilemaps (Grid)
3.1. Ground tilemap (Ground)
4. End of level (LevelEnd)Add the
Rigidbody2Dcomponent to thePlayerobject. Freeze its rotation constraint.Add the
Collider2Dcomponents and set them up to perform collisions for the following objects:
1.Ground
2.Player
3.LevelEnd(make it triggerable)The ground object should be created with the
Tilemapcomponents;Sort the
SpriteRenderer's order in layer as:Background<LevelEnd<Ground<Player
Example
Example 1: here is how your game may look like