Physics

Learn to add realistic and interactive behaviors to the game via Unity’s Physics Engine.

Introduction to Unity’s Physics Engine

Unity includes a built-in physics engine that simulates the behavior of physical objects in a game world. Rigid-body dynamics form the basis of this physics engine that models solid and nondeformable objects.

The physics engine calculates objects’ position, velocity, and acceleration based on the laws of physics, such as Newton’s laws of motion. It can handle collisions between objects, apply forces and impulses to them, and simulate the effects of gravity, friction, and other physical phenomena.

Unity’s Physics Engine operates independently of the rendering engine, which means we can use it to simulate complex physical interactions without affecting the visual aspects of our game.

Setting up a physics scene

To use Unity’s Physics Engine, we need to create a physics scene and add physical objects. Here are the steps to set up a basic physics scene:

  1. Create a new scene in Unity.

  2. Go to the “GameObject” menu and select “3D Object” to create a primitive object, such as a cube, sphere, or plane.

  3. Select the object and go to the “Add Component” menu to add a “Rigidbody” component. A “Rigidbody” component represents the physical properties of an object, such as its mass, center of mass, and angular velocity.

Get hands-on with 1200+ tech skills courses.