Book Image

Learning Unity 2D Game Development by Example

By : Venita Pereira
Book Image

Learning Unity 2D Game Development by Example

By: Venita Pereira

Overview of this book

<p>If you are looking for a guide to create 2D games using Unity, look no further. With this book, you will learn all the essentials of 2D game development by creating five real-world games in a step-by-step manner throughout the course of this book.</p> <p>Starting with a blank scene, you will learn all about the new Unity 2D toolset, which will enable you to bring your scene to life. You will create characters, make them move, create some enemies, and then write code to destroy them. After figuring out all the necessities of creating a game, this book will then assist you in making several different games: games with collision, parallax scrolling, Box2D, and more.</p> <p>By the end of this book, you will not only have created several small games, but you will also have the opportunity to put all your new-found knowledge into creating and deploying a larger, full game.</p>
Table of Contents (17 chapters)
Learning Unity 2D Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Physics 2D


Those of us that are already familiar with Unity are aware of the original Physics component. However, this component only works for 3D. There is now a new component specifically for 2D called Physics 2D. The Physics 2D Manager has the global settings for Physics 2D.

To access it, we do the following:

  1. Go to Edit | Project Settings | Physics 2D. We would see the Physics 2D Manager as shown in the following screenshot:

The Physics 2D Manager settings are as follows:

  • Gravity: We can set the global gravity that will affect all objects in our game. X is for horizontal gravity along the x axis and Y is for vertical gravity along the y axis.

  • Default Material: This is an assigned Physics 2D Material. By default, None is assigned.

  • Velocity Iterations: This is the number of iterations by the physics engine to calculate the changes in velocity of an object/body. The higher this value, the more accurate it is, but it is more expensive from the CPU's standpoint.

  • Position Iterations: This is the...