How to Add Rigidbody to a Gameobject in Unity | 3D Game Development

Posted January 25, 2020 by Joudet Ahsan in Game Engine, Unity

The unity engine simulates a real-world environment. And we all know that in the real world, there’s three states of material, solid, liquid and gas. If something is solid/rigid it can collide, it can move, etc. Any object in the game world is called gameObject. So from now on, we will use the word gameObject to refer to anything in the game.

This tech-recipe is all about understanding what a rigid body is and how to make a gameObject as a rigid body. What is a rigidbody? A rigidbody is something solid. Rigidbody is used to give a gameObject properties of a solid thing. It can respond to gravity, can have mass, we can set it to have drag settings, etc.

Some objects need not react to gravity. You can set it to kinematic. For example set trees, plants and stuff that need to stay at one place to kinematic.

A gameObject to be properly solid, rigidbody attachment is not enough. You have to attach a collider to the object. There are many types of colliders. For example, if you’re attaching a collider to capsule shape body you can attach a capsule collider. There are other shapes as well such as polygon which covers irregular shapes.

The Mesh Collider takes a Mesh Asset and builds its Collider. A collider doesn’t need to be exactly the same shape as the object’s mesh – a rough approximation is often more efficient and indistinguishable in gameplay

So to make an object solid and collidable follow the following steps.

How to Add Rigidbody to a Gameobject in Unity

Add a cube/ or any Gameobject that you want to make

Set the cube on the plane/terrain whatever is the base of your game

Click on the gameObject, go to the inspector and click “Add component

Click on Rigidbody

In the same way, click “Add component” and add box collider.

If the object is not rendering(displaying on-screen), make sure you have mesh renderer added.

We have already talked about collisions in a previous tech-recipe check it out.

How to Detect Collision in Unity | 3D Game Development

Check other Tech-recipes as well

How to Set Out Of Office Autoreply in Gmail for Android

How to Manage Labels Easily in Gmail for Android

Uber for Android App: How to Add and/or Change Payment Method

How to Set Out Of Office Autoreply in Gmail for Android

 

 

About Joudet Ahsan

SEO Content Creator, a Computer Scientist in making and someone who sucks at writing bios.
View more articles by Joudet Ahsan

The Conversation

Follow the reactions below and share your own thoughts.

Leave a Reply