Chapter 1. Introduction to Physics in Unity3D

Physics has been used for a long time in different sectors such as scientific, study, and software. The use of Physics in interactive development and software is not new, but its use has been the focus of special attention in recent years.

At first glance, Physics gives the impression that it's all about long, webbed equations and calculations. However, the contributions of Physics are tremendous and have made developer's life easy. The idea of gaming was possible only because of Physics. All of us remember our childhood games, which were facilitated by the use of Physics; for example, the Ping Pong game. Isn't it amazing how much Physics has touched our lives and how we cannot escape its influence? There are many games that possess primitive Physics, used to calculate the movement and trajectory of a bouncing ball. If you look into the structure of Physics used for one of the earliest games, Pong, you get a brief insight into how Physics was used in these games. Game behavior, motion trajectory, and paddle movement were all handled by primitive Physics.

In this chapter, we will learn about the following topics:

  • How Physics is used in interactive development
  • The basic components of Physics for interactive development
  • Physical simulation in Unity

In today's interactive world, the use of Physics is changing day by day. In recent years, the use of Physics in games, software, and interactive development has increased drastically. Now, we are able to make games and other applications using Physics in different ways. In the modern era, the importance of in-game Physics and interactive development has increased.

If you look at the way Physics was used in older interactive applications or games, you will find that they were all based on some specific scenarios. The Physics code was written according to the scenario of interactive development. For example, if the Physics code is written for a ball to handle its trajectory motion, it only handles the trajectory motion and nothing else; this means that every time a developer has to write a new code for a new effect. Also, with the passage of time, if an update is required, the developer has to modify or even rewrite the code. Based on such cases, development became very complicated and time-consuming. Conditions became worse when the number of scenarios increased. As mentioned earlier, the way Physics is used is changing day by day, and it is required in various sectors. Let's take a look at the areas where Physics is widely used these days:

Introduction to Physics in Unity3D

Physics is useful in the following areas of interactive development:

  • Real-time programming where we need knowledge of electronics, which is much related to Physics
  • A Physics engine for graphics software or games, where Physics is heavily used
  • Creating 3D programs for various software and game engines
  • Physics-based simulations

The most common component of Physics used in interactive development

Rigidbody dynamics is the most common component used in interactive development. For Physics-based simulation development, we use algorithms of Rigidbody dynamics. Rigidbody dynamics is based on the Newtonian principle of movement and mass.

Now, the question that arises here is what is a Rigidbody? An idealized solid whose size and shape is fixed and remains unaltered when some external forces are applied and is used in Newtonian mechanics to model real objects is known as a Rigidbody. For example, a box, wall, and so on.

The use of accurate Physics in interactive development is not feasible as it has its own natural constraints. In interactive development, we cannot use accurate Physics due to the standard frame rate restrictions, but the physical accuracy of a simulation only needs to be believable.

Use of Physics in simulation and frame rate

In order to use Physics for interactive development, there are many things that need to be taken care of. Physics simulations are related to the frame rate. The frame rate can be described as the number of frames that are displayed per second. This is relevant to animation, in which many images are displayed quickly to give the impression of movement. The standard frame rate for most PCs and console games is 60 fps.

The interval of moving objects with their trajectories is called Physics simulation. Almost every Physics simulation equation involves time, and the time required for solving this is determined by interactive development.

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

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