What is a RigidBody in Unity?


In this arti­cle we are going to see the Rigid­Body com­po­nent in Uni­ty, what it is for and how to use it. Know­ing about this com­po­nent will allow you to cre­ate pre­cise physics in your game.




What is a RigidBody in Unity?

First Rigid­Body in Uni­ty is a "Pro­gram­ming Class" defined at the core of the engine and acces­si­ble via Script using the name­space "Uni­tyEngine". This in sim­ple terms means that it is a pro­gram­ming struc­ture that seeks to mod­el a par­tic­u­lar type of behav­ior. Here you can see an intro­duc­tion to class­es in pro­gram­ming.

Rigid­Body means Rigid Body, which in the study of physics is a way of think­ing about cer­tain objects and being able to make cal­cu­la­tions and pre­dic­tions in dif­fer­ent scenarios.

The Rigid­Body class mod­els the con­cept of Rigid Body in physics and allows us to treat GameOb­jects as if they were phys­i­cal objects that have their own mass, are affect­ed by grav­i­ty, can col­lide with oth­er objects, exert forces on oth­er bod­ies, have a coef­fi­cient of fric­tion depend­ing on the sur­face they are on, have lin­ear and angu­lar veloc­i­ty, iner­tia, angu­lar momentum.

To these bod­ies we can apply forces or torques and these Rigid Bod­ies will respond based on the clas­si­cal equa­tions of New­ton­ian physics. Beautiful! 

What is a GameOb­ject in Unity

Rigidbody Component in Unity

In the Uni­ty hier­ar­chy we have the list of GameOb­jects that are in the scene. If we choose one of them, we will be able to see its com­po­nents in the inspec­tor and add the ones we need to mod­el its behav­ior. Here we can add to the GameOb­ject the Rigid­Body com­po­nent that will pro­vide the phys­i­cal Rigid Body behavior. 

Colliders and RigidBody

Col­lid­ers are fun­da­men­tal to being able to use a GameOb­ject as a Rigid Body, as they pro­vide the GameOb­ject with a bor­der to deter­mine when it col­lides with oth­er objects.

In the fol­low­ing video you can see dif­fer­ent types of Col­lid­ers and in the final part how it relates to the Rigid­Body com­po­nent. Eng­lish Sub­ti­tles available.

Colliders and RigidBody in Unity

Apply forces to a RigidBody in Unity

Because Rigid­Body is a class, it has a vari­ety of pub­lic meth­ods that allow you to access your inter­nal state or per­form cer­tain func­tions. Among them is the pos­si­bil­i­ty to apply a cer­tain force to the GameOb­ject. With the fol­low­ing instruc­tion you can add a force to a Rigidbody:


Where "aRigid­body­Compo­nent" is a vari­able which has the ref­er­ence of a Rigid­body com­po­nent and "forceVec­tor" is a vec­tor that describes the force to apply, that is to say its mag­ni­tude, sense and orientation.


Rigid­Body is a Pro­gram­ming Class defined in the engine core, acces­si­ble by the name­space Uni­tyEngine. This class allows us to give GameOb­jects the behav­ior of phys­i­cal Rigid Bod­ies with all that entails.

Col­lid­ers are essen­tial to delim­it the Rigid Body bor­der and to cal­cu­late forces and col­li­sions with oth­er GameOb­jects with RigidBody.

Using the pub­lic meth­ods of the Rigid­Body Class we will be able to apply forces, lin­ear and angu­lar veloc­i­ties, torque and mod­i­fy a great vari­ety of prop­er­ties present in the study of New­ton­ian physics.

Scroll to Top
Secured By miniOrange