Web Class: How to Create a 2D Platformer Controller

Web Class: How to Create a 2D Platformer Controller

You can access the full course here: Develop a Puzzle Platformer Game

Transcript

Hey guys! In this first lesson, we’re going to set up our character controller – which is going to require that we import the Standard Assets that Unity provides for us to use that platform character controller. And we’re going to get it set up in our scene with a simple little ground object just so we can get our player up and running so we can get started making our game.

We’re going to start from a blank project here. I am In Unity Hub 2.0, which looks a little different than 1.9 and back, but overall it’s just the same process here, I’m gonna create a new project and I’m gonna create it in the latest beta version available to me which is 2019.2. And I’m going to create a project called Industrial Jones, and it’s gonna be a 2D project. Now this doesn’t necessarily matter here, but it’s just gonna set up our project with some 2D settings that we can change ourselves if we wanted to later on. Then click create project.

So in our blank project, I’m just gonna make sure I’m on the same layout by going up to Layout and going to Default so we have the exact same set up here, and what I want to do is go over to the Asset Store tab. And we’re going to find the Standard Assets that Unity provides by just saying standard asset. And we’re going to download and import these into our project.

Now this includes a few different packages that we do not need. We only want the 2D character controller that gets our platformer up and running very quickly. So what I’m gonna do is I am going to go through them. I don’t think I need any of these scenes, so I’m just gonna turn off sample scenes entirely.

And in Standard Assets I do not care about let’s just collapse all of this here, I don’t want vehicles, utility, prototyping, physics materials, particle systems, fonts, environment. And in the editor, I do not want the water – I do want the cross-platform input though. We do not need the characters folder, it’s just 3D stuff. So we’ll import the entire 2D folder, cross-platform input, and the editor for cross-platform input.

Now we get an error for that, but that’s fine. We can just clear that out and right click and create a 2D object sprite. It’s just gonna be our ground object for now something for us to walk on. So I’m just gonna change the sprite to let’s see, we’ll just make it, doesn’t really matter just a platform just like that, and we’ll just stretch this out here. Just something to walk around on for now. In the next lesson, we will create an entire level based on tiles.

I wanna add a component to this that is going to be a Box Collider 2D. So we can collide with the platform with our player. And speaking of our player, let’s go into our 2D Standard Assets folder here, and I wanna go to Prefabs. And we have some stuff in here, but all I care about is breaking out my character controller and dropping him right inside my scene. And I wanna name this guy Player. Just like that.

And what I, in fact, wanna do, is I wanna create a new folder in my assets folder here, and I wanna call it Prefabs. I wanna have my own separate prefabs from the Standard Assets, and I’m just gonna take my player drag it into Prefabs. And I wanna create an original prefab. Now we could create a prefab variant, which means the base changes of our original prefab would still affect this guy, but we could add changes on top of that. But I just wanna create an entirely new prefab that I have complete control over just like that.

And now watch it happen here – if I were to click play my guy should fall and land on the platform. There we go, and I can just use my WASD or my arrow keys or a controller to move this guy around and Space to jump. Now it’s a very floaty jump and we can get into tweaking all that later on, but for now our guy is running around in our scene. Pretty cool.

So in the next lesson, guys, we’re going to start building our first level. It’s gonna be a very simple level with just some ground tiles and some wall tiles and then, later on, we’ll add in hazards. And then we’ll add in enemies and we’ll add in keys and doors and just all kinds of really fun stuff. So my name is Austin, and I will see you in the next lesson.

Interested in continuing? Check out the full Develop a Puzzle Platformer Game course, which is part of our Unity Game Development Mini-Degree.