Chapter 9. Starting Your First Game

This is it! We have done some basic planning. Now let's begin the project and build your first game. In this chapter, we will cover the following topics:

  • Setting up a new Unity project
  • Backing up
  • Good practices to keep your project clean
  • Preparing the player prefab
  • Brief introduction to physics and the Rigidbody component
  • Collisions and triggers
  • Adding physics force on input
  • Update function versus FixedUpdate
  • First gameplay

Setting up a new Unity project for our game

There are a few basic but important things. Create a new project in Unity. Save it in an easily accessible place. Make sure you have switched the project type to 2D. It will save us some time while importing assets such as Sprites or textures. There's nothing to worry about here; just make sure you select 2D, as in the following screenshot:

Setting up a new Unity project for our game

Backup

Backing up isn't a direct topic in this book; however, I really want to highlight how important this is. Backing up your files will definitely save you from disaster at some point. Lots of things can happen, from hardware failure to rare internal Unity bugs that can ruin your project. That's why it's wise to have a copy of your project somewhere. I don't want to tell you how you should back up your files. There are many ways of doing it, and some are very simple and free.

I would love to tell you a lot about version control and ways to secure your project. However, version control is a rather advanced topic. We will leave it for now. I recommend zipping your project at least once a day and keeping it in one of the cloud storage services such as Dropbox or Google Drive.

Keeping your project clean

Another very good practice that I want to teach you before we get into developing your first game is the importance of keeping your project structure clean.

Unity is very flexible in terms of file placement in the Assets folder. This is good but it can get you into trouble if you overuse it. Let's set up a few rules that we will follow to make sure our project won't end up being messy:

  • We'll keep all Assets files inside subfolders and not in the root of the Assets folder
  • We'll always name files in the best possible way
  • We'll never call any files test; if you are importing a test asset, name it test_xxx where xxx explains what the file actually contain

Another tip that I can give you is to keep subfolders organized. Have a look at the following screenshot that shows examples of a bad and good project structure. On the left-hand side of the screenshot, you can see shockingly disorganized files. There are files placed in the root of the Assets folder and different types of files are placed next to each other. On the right-hand side of the screenshot, you can see how I want you to organize your projects. Keep it neat and clean. You won't regret it when your simple project grows into something bigger that is still easy to manage.

Keeping your project clean

We are ready to start game development now. We have a rough plan and Unity is set up for the job. Let's finally start now.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset