From the course: Unity 4: 2D Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding collision to the player

Adding collision to the player - Unity Tutorial

From the course: Unity 4: 2D Essential Training

Start my 1-month free trial

Adding collision to the player

So now that we've created our player prefab, let's create a new scene so that we continue adding logic to our player's prefab. We're going to create this new scene. Hit Save and call this scene PlayerStaging. Make sure we save this into the Scenes folder. Now we can drag the player prefab back into the scene. If you remember back to when we were setting this prefab up originally, if we played this scene the player isn't being effected by gravity. We can change that by adding a specific component that part of the Physics 2D engine inside of Unity, called a rigid body 2D. Unity uses box 2D as its physics engine. By adding a rigid body, 2D, to the game object, we're telling the physics engine that gravity can be applied to it. If we were to run the game, you'd expect the player to fall down. But what actually happens is he slowly moves up. If we stop this and take a look at the animator, you'll see that apply root motion is automatically selected. By unchecking this, the player will now…

Contents