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
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.
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,
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.
Next: Collision or Trigger