"Sprinkles may seem soft, but they are an excellent sharp weapon against sweet-tooth pandas, who are trying to steal your delicious cake!"
This chapter explains how Unity deals with 2D physics and provides descriptions for each of the components, along with useful examples of usages. Although we will use just a small portion of the Physics engine of Unity for our game, in this chapter you can find some foundations of physics to better face the topics covered, and a full insight of 2D physics in Unity.
In the first part of the chapter, we will acquire some basic notions about physics so as to better face the topics to come. We will learn about mass, forces, and torques, just enough to understand physics in Unity.
Then, most of the chapter will focus on explaining, bit by bit, the 2D Physics engine of Unity along with all its components and functionalities. Many examples will be provided in order to facilitate the learning.
Finally, in the last part of the chapter, we will use some of the notions learnt and apply them into our game. In fact, we will transform simple sprinkles into terrible weapons against the sweet-toothed pandas by enabling and handling collisions between the two.
Therefore, we are going to learn these topics:
Like all other chapters in this book, you will find the Homework section at the end. It has a range of different exercises for you to do to improve your skills and implement a range of different functionalities into your game.
This chapter does not need any particular prerequisite to learn about the Physics engine. However, at the end of this chapter we will continue our tower defense game from where we left it in Chapter 4, No Longer Alone – Sweet-Toothed Pandas Strike. Therefore, if you want to keep developing the Tower Defense game, you need to have done all the other steps in the previous chapters.
For those of you who are newcomers to physics, a great deal of patience is required, but once you master these concepts, a world of new possibilities for your own games will open. So don't give up!
3.145.54.7