Chapter 5. The Secret Ingredient Is a Dash of Physics

"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:

  • Basic notions of physics
  • Understanding the Physics engine of Unity
  • Physics settings, which are general properties for the whole project/game
  • Rigidbody components with different body types and their usage
  • Colliders and how to use them
  • Joints to impose constraints on rigidbodies
  • Effectors to change physics properties in particular region of the game world
  • Physics materials to determine friction and bounciness on colliders
  • Using the physics components in our game

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.

Getting ready

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 4No 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!

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

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