A Little Physics in Unity- Game Dev Series 08

Physics is what makes a game more realistic and more fun.

Previous: A Cooldown System

So far we have made some movement and shooting action. The next part would be create an enemy. Before we create an enemy, we should know the basic physics in Unity- Rigidbody.
Rigidbody can make our game object to interact with real world physic, such as gravity.

We can create a rigidbody simply by add a component insides Inspector window.

A rigidbody component for a 3d object

The first thing you would notice the different is gravity. When you play with a game object that contains a rigidbody with gravity checked, it would falls straight down as gravity is dragging it.

You can see the difference by check the gravity

With rigidbody, you could even create a lot of ways to play with gravity.

A rigidbody is usually used with collider. As the name, a collider is used for process the collide between game objects. Without the collider, the game objects would go through each other. In our game, a collide would happen between the laser and the enemy, or the enemy and the player.
We will talk about collider later, let’s create an enemy now.

Create a cube and change the name to Enemy. Then add a rigidbody component to it.
You can hit Play and see what would happen,

Don’t forget to give your enemy a material

The enemy was falling straight by gravity and stopped above the Player because the collider. When we create a new game object, there is always a collider attached to it.

That’s the first step to play with rigidbody. Next, we will make the collide more reasonable.

--

--

--

A passionate gamer whose goal is to work in video game development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Intent classification — algorithms, datasets, what is it and how to use it to create realistic…

Let’s Create A CLI With Python — Part 2

Node.js : Stored procedure middleware

Setting up Cassandra Multi-Site on Google Kubernetes Engine with Casskop

Node.Js VS Ruby on Rails

Steam VR Updates: How to Setup Teleport Mechanics

Learn SCSS (Sass) Part 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
S.J. Jason Liu

S.J. Jason Liu

A passionate gamer whose goal is to work in video game development.

More from Medium

How to Install the Universal Render Pipeline- Game Dev Series 149

Coroutines in Unity

Screen Space Reflections In Unity

Learn to code by making a 2D space shooter game.