The Ultimate Guide To C# Unity 2D Programming (2020) | Michael Murr | Skillshare

The Ultimate Guide To C# Unity 2D Programming (2020)

Michael Murr, Software Engineer :: Game Developer

The Ultimate Guide To C# Unity 2D Programming (2020)

Michael Murr, Software Engineer :: Game Developer

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
48 Lessons (10h 13m)
    • 1. Introduction & Course Structure

      4:17
    • 2. Section 1: How To Download Unity & Visual Studio

      5:28
    • 3. How To Work In Unity Interface

      9:23
    • 4. Writing Your First Code In C#

      12:17
    • 5. Section 2: Magic Game Cube 2D -Introduction To Version Control

      7:22
    • 6. Setting Up The .gitignore File

      8:53
    • 7. Print Using Debug.Log()

      8:02
    • 8. Variables 101

      9:19
    • 9. Responding To Player Input

      9:33
    • 10. Adding Rigid Bodies & Colliders

      10:25
    • 11. Adding Magic To Our Cube

      7:18
    • 12. Using If, Else If, Else Statements

      11:04
    • 13. Public Methods & Return Types

      15:32
    • 14. Prefabs And Parent Child Relationships

      13:52
    • 15. Section 3: Setting Up Our World - Game Design

      11:06
    • 16. How To Slice Up Sprites In Unity

      7:25
    • 17. Tile Maps In Unity

      14:29
    • 18. Rule Tiles 101 (2D Extras)

      13:06
    • 19. Adding Our First Animations

      13:56
    • 20. Animation Transitions

      12:28
    • 21. Adding 2D Collisions

      8:30
    • 22. Section 4: Moving Our Conqueror Horizontally

      14:45
    • 23. Flipping Our Players Sprite

      9:17
    • 24. How To Trigger Animations From Code

      7:59
    • 25. Adding The Ability To JUMP!

      12:25
    • 26. Tweaking Jumping Using IsTouchingLayers()

      10:42
    • 27. How To Prevent Wall Jumping

      7:39
    • 28. How To Add Climbing Mechanics

      16:11
    • 29. Tweaking Climbing Mechanics

      5:27
    • 30. Cinemachine Follow Camera

      12:19
    • 31. Cinemachine Confiner Extension

      13:12
    • 32. State Driven Cameras

      11:48
    • 33. Section 5: Adding Enemies And Bombs - Making Enemies

      23:28
    • 34. Player Hit

      17:23
    • 35. Drop The BOMB

      17:17
    • 36. Exploding Our Conqueror

      14:22
    • 37. Adding The Attack Ability (How To Use Arrays)

      20:32
    • 38. Killing Off Our Enemies

      13:48
    • 39. Section 6: Controlling Our Game - Adding Levels

      12:25
    • 40. Exit Door

      24:12
    • 41. Main Menu & Success Level

      18:49
    • 42. Game Session

      14:47
    • 43. Hearts and Diamonds Pickup

      12:09
    • 44. Adding Sound Effects (SFX)

      10:51
    • 45. Persistent Lives And Score

      14:31
    • 46. Bonus Section: Level Enter

      18:11
    • 47. Adding SFX To Everything

      29:55
    • 48. Adding Hearts UI

      14:46
42 students are watching this class
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

387

Students

--

Projects

About This Class

This course is made with the latest content and newest technics used in modern Game Development (Unity 2020)

The best way to learn anything is by doing it in a really fun way and this is where this course comes from. If you want to learn how all these incredible games you see are made there is no better place to start than this course. We made sure that this course has everything you need to take you from a beginner (even with zero codding experience) and slowly take you to intermediate and finally become a professional.

I chose the main project in this course to be a 2D platformer because it not only has a vast library of game development concepts that we can implement and learn, but also because it's very simple (especially if you are a beginner) to delve in and get started on your game development journey.

Everything in this course has been meticulously crafted, review and recrafted to provide you with the best experience possible and maximize your learning as much as possible. So not only will you have a great time learning you'll also get the MOST BANG FOR YOUR BUCK by going away from this course with a lot of tools in your arsenal to continue you journey in the wild west of game development.

Section 1 - Introduction & Setup:

We'll start off by downloading all the necessary tools that we need to start our game development journey. That means the latest version of Unity and the latest version of Visual Studio. We'll also go over everything you need to make you feel right at home and how to use the course to maximize your learning potential. We'll finish off by creating our first code with a very simple game just to take the pressure off

Section 2 - Magic Game Cube: C# & Unity Basics:

This is where things get heated up. We'll start by leaning what Version Control is which is an incredibly powerful tool for game developers and used by professional programmers around the world. We'll learn the basics of C# so even if you have ZERO CODING EXPERINCE you can still understand everything and learn how to build great games and continue on with the project. We'll also get a grasp on the fundamentals of Unity Engine and how everything works in it

Section 3 - Castle Conquest: Setting Up Our World:

We begin our Main Project. We'll start off by setting up our world, and what better place than the Game Design and player experience of our game. We'll add sprite sheets slice them. You'll learn how all these maps in 2D platformers are so easily created and understand how it's not as hard as it seems. We'll add our character who's a great Conqueror wielding his trusted Hammer and you'll get your first taste of animations

Section 4 - Castle Conquest: Creating Our Conqueror:

Here is where you go deeper into making our character feel alive. We'll give him the ability to move in the levels we created and interact with various things like the walls and so on. Our Conqueror will jump, climb, run, flip and just stand there sometimes Idling. We'll also implement a modern game development technique called CINEMACHINE that makes our game really cool and professional

Section 5 - Castle Conquest: Adding Enemies & Bombs:

It's where things get a bit scary because our Conqueror is no longer safe. There are new threats inside his castle with pigs roaming and bombs ready to explode at any moment. We'll add enemies, animated them and make them hurt our Conqueror if he walks too close to them. We'll also add hazards like bombs that blow our player up if he doesn't keep a safe distance after they start burning

Section 6 - Castle Conquest: Controlling Our Game:

This is where we add lives to our player, we add more levels and add a score to get anyone playing our game a goal that they should achieve. Make everything in our world much more interesting and fun to experience. This is also where we add Sound Effects to our world and really make everything come alive

Bonus Section:

This is where we do a little bit extra. We delve deeper into the UI canvas of our game and make it much better to look at. We add all the SFX we have available, so that everything we interact with has a sound attached to it, and finally we tweak the progression of the levels by adding a couple of new animations to our player

What You Will Learn In This Course:

  1. Download and install Unity and Visual Studio

  2. Why we need Visual Studio with Unity

  3. Use Visual Studio with Unity in a simple way

  4. How to set a good Game Development environment

  5. Unity Engine are in a simple and comprehensive way

  6. The Basics of C# in the most fun ways possible by creating a game

  7. Use player input to control the behavior of our game

  8. Add different component to game objects

  9. Add gravity and other forces to game objects

  10. Make game objects interact with each other in our game

  11. Add sprite sheets and slice them up

  12. Create Tile assets

  13. How to create levels from our tile assets

  14. Become a ninja problem solver and learn how to go step by step to solve any problem in Game Development and coding

  15. Create animations

  16. Make transition between animations

  17. Add climbing mechanics

  18. Add bombs that explode and kill player

  19. Add enemies that attack you

  20. Create levels automatically with 2Dextras

  21. Learn what player experience is

  22. Add sound effects to your game

  23. Add a scoring system to our game

  24. Add lives to our player with dying conditions

Meet Your Teacher

Teacher Profile Image

Michael Murr

Software Engineer :: Game Developer

Teacher

Hi there, my name is Michael Murr. I'm a software engineer from one the most highly esteemed universities in the middle east. 

I started coding when I was about 11 years old when my dad taught me my first lines in HTML and I have never looked back.

Now a Software Engineer with more than 10 years of experience.

Over the years I've helped hundreds of student create game, learn how to code and set their life up for opportunities in many field that require a software programming skillset. And I will help you do the same.

I have a complete mastery of Python, C#, JAVA, C++ and my aim is to teach you all of these and more in a fun way.

I cannot wait to help you start on your journey and help you along every step.

I'll see you very soon!

<... See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Your creative journey starts here.

  • Unlimited access to every class
  • Supportive online creative community
  • Learn offline with Skillshare’s app

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

phone

Transcripts

1. Introduction & Course Structure: My name is Michael Moore, founder of double m game dev. And my goal is to make you the best game developer in the most fun way possible. I've helped hundreds of aspiring game developers achieved their goals of creating fair game. And I want to do the same for you. What I've learned is that it can be very difficult to know where to start when it comes to game development and what steps to take to go from beginner to intermediate to professional, not only in game development, but in programming and learning how to go. And I can say with absolute confidence, this course makes it easy for any beginner with 0 coding experience to jump in and learn how to make great things. What's even more amazing is that this course is made using the latest version of Unity 20-20 was the newest possible content and techniques used and modern game development, I've held hundreds of people create real-world games, and I want you to be one of those people. So how are we going to do this, the course structure? So the first section, which we are currently on will be the production and the syrup, where I will introduce you to a unity if you're new to it, and introduce you to the Visual Studio and why will use it, will actually also create our first code and our first script, which is very exciting. The second section will be the magic Game Cube, basically will cover the C-sharp and unity basics. We'll talk about the basics of C-sharp and the tools that we'll need for our Golding later on. And the basics of unity and everything that we need to understand from collisions to rigid bodies, to physics, immunity and so on and so forth. Now the third section is where things will get very interesting. And it's our project which is Castile conquest to the, and in the section three, we're going to be setting up our world. We are going to be creating our tile sets. We are going to be creating our world, adding collisions to let world and adding our player, but not so fast cousin in section four, we are going to be adding our conqueror and we may have, we may introduce our conquer and d, Section Three Button section four. We're actually going to give him the abilities to Shawn, to run, to have different animation and so on and so forth. Now, section five is where things get a bit scary because we're adding enemies and bombs. So now our player as no longer safe, he will have to fight off enemies and he will have to avoid bumps along the way as he tries to conquer the Gaza. And in section six, we'll start controlling our games. All be adding, a score, will be adding the lives, will be adding multiple level store game and everything that goes on with it will actually also be adding a lot of sound effects and make our theme much cooler. And finally, in section seven, we'll have the bone section will be where we tweak things a bit and just for the fun of it, make our game a bit more exciting and more fun. You'll also have the chance to flex your game developer muscles, because in every video there will be a mini challenge for you to complete. And even if you can't figure out how to do it, don't worry about it. I will be there to help you up to retry and complete the challenge with everything. And our gain will be configurable. So you can tweak, play around and give the game and individual S special feel about you'll be putting your own creativity into it and really making it your own. I'm so excited to get started and hope you are too. This is the perfect time to start learning how to code, especially in times like these. So diving with me and I will help you along every step of your game development jury. And I'll see you in the next video. 2. Section 1: How To Download Unity & Visual Studio: Welcome back everyone. So in this video we are simply going to be downloaded in the unity, how installing our version of Unity and setting up everything in order to start creating games. So let's get started. First thing you need to do is you need to go and to whatever browser you're using. I'm currently using Google Chrome. It doesn't matter. Simply go ahead to Google and type in download unity hub, and you should get this search result. So simply go and click on the download unity hub. It should be the first link which would be on the Unity 3D.com website. And it will take you to this page right here, and it will ask you to download unity hub. Now, what is unity hub? Well, unity hub is a place where we can add different versions of Unity. And we can also have all of, all, all of our project represented very neatly and very carefully, which is very helpful and much better than the way we used Unity before. So simply click on Download unity hub and you should get the installation which is right here, which is unity hub setup. So double-click on that. It will start an installation. It's fairly easy. You simply click on agree and install it. And wherever destination folder that you have, I already have unity hub, so I won't bore you with the download process. It will ask you to agree to something which is fairly easy. So go ahead and install Unity hub. Oh, okay, so now that you have unity hub and stall, you should get this window right here. And first thing you'll need to do because I'm already signed in, so you need to create an account. I'm currently using my Google email, which is very helpful and much easier. And here you can see that we have all of our projects, not currently, we don't have any projects yet, but we will very soon. Here you have different tabs for learning and for the community, which you can go and check out and see what there is. But what we're going to focus on right now is going into installed. Now as you can see, I already have a version of Unity, which is 2020.1.21. So maybe you're from the future and you have a better version or a more, or a newer version. And in order to add a new version, you simply click right here on the app. So when you click on Add, it gives you different options to download unity. Now as you can see, you have recommended releases, you have official releases and you have pre release. Now, what should you choose? Well, personally me, I like to choose the official releases because they are usually the least buggy. There is the recommended release which is also not bad. And there are the pre-release press releases. And now press releases are not always bad buggy, but sometimes you may encounter not very good performances during play or during the game creation. They are not that common, but I personally prefer the official releases. So go ahead and choose one of them. Let's choose the official release of 2020.1.10. And let's click on Next. Now, this should take you to another modules to your installation window. And what we have here is a bunch of add-ons and uses for the unity. So for example, you have Android belt, which will help you build games for Android, you have line next built support and Mac and so on and so forth. You also have the documentation which I recommend you download. And you have the language back, which if you have some kind of different language, Chinese or Korean, I'm not sure what those are. You can also check one of them and download that. But most importantly is you have to check this developer tool, which is Microsoft Visual Studio Community 1019. Maybe you have a newer version. So this is absolutely a must. We will be using the Visual Studio to code all of our games. So go ahead, click on those and click on Next. And the download should start right here while you're having a box similar to this one and with a little blue bar up here waiting to finish the download. So now I'm going to introduce you to your challenge, and this is your challenge for today. So you need to download unity and Visual Studio. So first of all, go ahead and download unity hub. Then download unit is latest release. And make sure you also download Visual Studio with unity. So go ahead and do the challenge, and I'll see you in the next video. 3. How To Work In Unity Interface: Okay, so welcome back to another video. Let's see what is unity? So unity is a cross-platform game engine development developed by Unity Technologies. We'll use Unity to develop our game. So what does cross-platform means? It means that we can use it on different platforms. And it's a game engine. And what game engine is, it's a environment for us to develop games and add physics and add different things to create our game. So let's check out what Unity actually looks like and I'll explain a couple of things on it. So this is Unity. First of all, we have this toolbar right here up above everything. And this provides access to the most essential working features. On the left, we, it contains the basic tools for manipulating the scene view and the game objects within it. In the center we have the play, the pause and the stub Control button. And the buttons on the right gives you access to the Unity collaborate, unity cloud service and Unity account, and will not get much into that. On the right side of those, we have the layer visibility unit menu. And we have the editor, which provide some alternative layouts for the editor window and allows you to save your own custom layouts. So if you don't have the same layout as I do, you can simply click right here on layout and you can choose the default layout. And this is the default player that we have. It's the projects right here and inspector and everything. Next thing we'll talk about the hierarchy window right here. It's a hierarchical text representation of every game object and our scene. So each item in the scene has an entry in the hierarchy. So the two windows are inherently linked. The next hierarchy reveals the structure of how game objects attached to each other. So right here we have the sample scene. And if we click on that, we have the main camera under it. And if we add another game object, it will also show up right here. And here is the inspector, as you can see on the right. This is the window inspector and it gives, it allows you to view and edit all the properties of the currently selected game object. So don't select a game object, we don't see anything. When we click on main camera, we have these different windows right here, and the layouts and counter contents of the inspector window changed each time you select a different game objects or now we don't have a different game object. So we'll just settle for the camera. Next. Then we have is this scene view right here. And the scene view allows you to visualize and navigate and edit your seen the scene view. I can show you either a 3D perspective or a 2D perspective depending on the type of project that you are using. So in scores will be using the 2D project view, but you can also write here collect on the to the button and it will go 3D. As you can see, we have this 3D view but we won't be needing, it will simply go into the 2D mode. And finally, I want to talk about the project window right here, which displays your library and assets that are available to use in your project. So when you import assets into your project, they will appear right here. So for example, for now we don't have any assets, would only have the scenes folder. And inside the scenes folder, we have this sample folder. So this is a quick overview of unity and what all those panels and gadgets are. We will, of course, delve deeper into them as we go through the course. But now I want to talk about the, something very important and that is the Visual Studio. So what is Visual Studio? Visual Studio is a Microsoft Visual Studio. It's used well, it's developed by Microsoft and it's an IDE. And IDE is an integrated development environment. And what it does, actually, if you ask me in Visual Studio, will help us write the code used to manipulate game objects in the Unity using something called scripts. So how to use Unity with Visual Studio? So we need a way for unity and Visual Studio to communicate. But they do not simply do that. We need to add something to it called the dot cs file, and that is our scripts. And those scripts, we actually take those scripts, we attach them to game objects. And using those scripts will be able to add behavior to different kinds of game objects. And we'll see that very, very soon. So let's go into Visual Studio and see what it's all about. This is Visual Studio. And maybe the first time you open it up, you'll have different panels right here on the right, and different windows right here on the left. Feel free to close all of them. And don't worry about what happens next. Of course, you won't have this the first time you start up Visual Studio, but you'll see it soon enough. And I will just introduce you to a couple of lines of codes right here. So let's zoom in just a bit. And right here on the top you can see that we are using system collections. We are using stamp collection collections generic. And most importantly, we are using the Unity engine. What are all of those? While those are called namespaces. And basically, these are libraries that give us the opportunity to use different kinds of coat. So for example, Unity engine, which we added tried here, allows us to use fist start method and the update method and different engines to create games and make it much easier. And we simply write here using Unity engine. And it saves us a lot of gold and gives us the entire library to use. Next thing we have the public class class name. And this is the, actually the className, which should be right here. It will be the script that we've talked about and it will be attached to a game object. And it will encompass all of the code that will change the behavior of our game object and sidewall game and mono behavior is a base class and it's actually these two mean that it inherits from the mono behavior, which allows it to use different kinds of manipulations and engine and physics and so on and so forth. And next thing we have is the start and above it is something called the comments. Or whenever you write code and add these two lines right here, it will comment things out and comments actually don't get executed. And the GOP, the coat, coat, the code and they are perfectly safe. So it's start. Start is called before the first frame update. So as soon as our game starts, the start method and the scope of a method we'll start to execute. Next thing we have the update, and the update is called once per frame. So every frame that we have in our game, the update is called. So start is typically used to give the initial properties or configurations to certain objects. And the update is used for objects that maybe are moving or change every frame. So if we have a car, for example, and start, we can give it the color, the name, the speed at which it can go. An update will be moving the car, will be making the carbon jump will be making the car go faster, maybe increase its speed. So you get the basic idea of Visual Studio, and now it's time for your challenge. And your challenge is to go make aim mass. So open unity, create a project. And if you don't know how to create a project, we'll do that in the next video. And when you're finished, after you go make hay mass, go to the next video and we'll make our first coat and gets started. So I'll see you in the next video. 4. Writing Your First Code In C#: Welcome back, my fellow game developers. In this video, we are going to be creating our first code and our first game objects. So as you can see right here, we have a game object called Hello World in our heart and our hierarchy. It's present right here in our scene, although we don't see it very well. And we have the script right here attached to it. We've also created the script criteria in our project. And in console. If we click on play, we actually get a message that displays Hello Michele, which is me. But in your case it will, it's going to be displaying your name. So I'm very excited for this video because it's our first delve into Unity world. So I hope you enjoyed the video and I'll see you in just a bit. K. So first thing we're going to do is we're going to open up Unity hub. And currently you have no projects here, which will change in just the first thing we'll do is click on new right here. And we'll need to choose a template for our game. So we'll be creating a 2D game, not a 3d. And these are different options also for different project types. Next thing we'll need to add a project name. Feel free to name it. What ever you want will be calling it for now the Hello World project. And make sure that you choose a location for your Unity projects. So we'll click on this one and let's go back and save it inside of the Unity projects. So select the folder and now we have a location for our game. You need to do. All you need to do right now is click on concrete. So click on Create and Unity will start to create your project. And I will not bore you with the waiting here. I'll use the magic of editing and we'll simply jump into the project. So see you in a bit. Welcome back. So I hope your project also finished setting up. So this is our scene. If you don't have this kind of seen, as I've told you, you can always go to layout and choose the default layout. And we'll have the same layout, both of us. So before we start, let's first of all at something called the Console. And as you can see, even before we start anything, we have this console window right here. And what this does is it shows us the messages. And we're going to use this console window to see the things that will print from our code. And if you don't have it, you can simply go up here and window, click on it. And just above here, you can see on the general will have the console, so click on it, a window should appear and you can dock it wherever you want. I'm going to dock it right here next to projects. In other thing I want to talk about is in the, wherever you saved your project, I've saved it in D, Unity projects and HelloWorld. So as you can see, we have different folders right here. We have the assets. Hold our scenes and everything that we create and projects. You can see the assets and project assets right here. We also have the library which automatically created every time we enter a project, we have logs, we have packages, we have project settings, all although all of those are details that will not get into too much. And the temporary folder, which we'll discuss later on in the magic cube to the game. So let's go back into Unity. And in here we are going to be creating our skirt. So let's right-click in here. And let's go into create and create. We can actually create multiple things, as you can see, we'll do a couple of them in our project, but for now let's simply create a C-sharp script. So click on that. And before you do anything, so now don't do anything, leave everything. You'll need to make sure that whenever you name a script that you do it with precision because it will cause error later on if you want to try to rename your script. So make sure you name it correctly from the get-go. So we'll name this hello world without any spaces and click on Enter when you're sure that you have decided on the name of the script. So click on Enter and I'll tell you why in just a bit. So as you can see, we have something right here in the inspector. And that took a bit of time and it's because Unity needs to compile the code right here. And you can actually see the code in the inspector. And why I told you it's so crucial to make sure that the name of the script right here is defined before we click on enter as because it is going to be the name of our class. So if you change the name of our script right here, tick last name won't change. And there will be an error where unit or the Visual Studio will not be able to find the correct script in the project and this will cause errors. So to avoid that, simply makes sure that you name your script correctly and precisely from the get-go. Now, what should we do next? It's very simple. You simply double-click on Hello World and the Visual Studio should open up. And as you can see right here, this is what we've described a couple of maybe in the previous video. So what are we going to do in here? We are simply going to print something to our console and we'll do that inside of stock. So let's go ahead and print. So as you can see immediately, Visual Studio, our great friend starts to help us and it gives a suggestion for what we want to use, or we write the print and it gives us the suggestion. And now you can simply click on Tab and it will finish it for you. And now we open up our brackets and we can see that Visual Studio again helps us. And it tells us that we need to add a object message inside of here. And that object message is going to be a string. We'll talk about strings later. But for now, string is a string of characters that we put inside of these two quotes right here. So let's go ahead and add these two quotes a again. And now we write inside of these two quotes, hello world. So is that enough? Well actually, no, because if you see right here, we have the squiggly red line. And if we hover over it, it tells us that it expects a symbol, which is this one. And every line of code in C sharp, you have to add this semicolon right here. So save that. And now, because we've put it inside of start, as soon as we start our game, this message should be printed on the console. So let's try that. We go back into Unity and we go into console. But if we click on play, as you can see, nothing is being displayed on our screen. Why is that? Because it's not enough just to create a script, you actually need to attach it to an object. So let's create an object. And the way we do that, we simply go into our hierarchy. We right-click on here. We can create a empty game object. Click on that. And now we have a game object that go ahead, we can change the name of that game object. We'll call it. Let's call it Hello World object. Click on Enter, and below it you can see that we have the transform. And this transform tells us the position of our game object in the world. And up here we have the tools to manipulate. So if you click on the stool, we can actually put the object up or drag the object down, take it to the left or to the right and put it anywhere we want. And currently we cannot see we don't have anything to represent or game object. We simply have its ordinates and it's transformed. So let's attach the script of this game object. To do that, you simply click on the script and drag it into the hierarchy and to the Hello world object. So if you click on Hello work object right here, you can see that it has a script just below the transform attached to it. And now if we click on play in the console, we can see that we have hello world. Congratulations, you've just written your first code and you've just used your first game object to display something to the console. Go rake. And now it's time for your challenge. And your challenge is going to print your own. Thank. So instead of hello world, you'll need to print your own name. So change helloworld to hello. And instead of those three dots, of course it's going to be your own name. I'll give you a couple of hints. So add your name and size of the dots. Save Visual Studio. Always remember to save Visual Studio we using control as go to unity and click on play and check your console. So make sure it works. Pause the video right now and go do the challenge. Ow, kay, welcome back. How did you get wrong with that? I hope you tried your best and that challenge. Let's go into Visual Studio. And instead of world, I'm going to delete that and I'll put my own name, which is Michel. So hello Michelle. And we'll just add an exclamation or three exclamation points for the dramatic effect. And to make sure that you've saved your project, I'm endure a script. When you look up right here, you can see that it has a small asterix, as strict as strings attached to it. And to save that you click on, and that means it hasn't been saved. So a few hold Control, S, click on control. As you can see that the asterisked as Trixie disappears, and that means that script has been saved, GO back into Unity. And you can see that there is an asterisk right here, also next to the sample scene. So save that. And now if we go to console, you can see right here that we have this button clear. Or do you click down? You can see that we can click on Play. You can remove that. Feel free. It doesn't matter. We'll just remove it to see the changes that happened at now if we click on play, we will have hello Michelle, or hello, whatever your name as my fellow students. And that is all so clear that, that strive again, click on play. And Hello Michele. Hello, my favorite game developers. I hope you enjoyed the video and I'll see you in the next one. 5. Section 2: Magic Game Cube 2D -Introduction To Version Control: Hello everyone. In this video we're going to talk about version control. So what it is, how it works and why we need it, will also download source tree, which is this, a graphical user interface that will help us and make life much easier? Our goal is to reach a point where we have everything set up and ready to go. So let's not waste any more time and let's jump in. Version control. It's hard to learn, it's even harder to teach. But I cannot tell you how important is that you learn the skill. And especially if you are looking to become a professional game developer. So what is it? What is version control? Well, basically it's a system that is responsible for managing changes to your computer programs. So anyway, version control is a way for us to record the history of our project. We needed to control the version of our project and have a backup to every single one. Which means it helps us to take risky steps in our project and avoid breaking the entire project. Why use it? Well, we'll use it to remember previous versions of our game and have more flexibility to experiment. It's especially helpful when it comes to creating games, because game development requires a lot of experimentation. What we will be using is a version control system called Get. There are other ways, but this one will work perfectly for us. And finally, we'll be using a graphical interface that makes our life way easier, which is called source tree. We can also have an online horse, but we won't be hosting just for now. Now, first thing you need to do, you need to go ahead and download source tree. Simply write source three or go to source three, ABC.com, or write source tree download on Google. And you should come up to this page right here. You can either download for Windows and it's also available for your Mac OS. When you finish downloading, you, you should have this installation file right here. Simply double-click on it and start the installation. And when you arrive, you should arrive at this point right here, where you have source three installed. So simply click on Agree right here. And then it should take you to the next slide or window, which is either to create an account. So you either use an existing account or you can go to my adolescent and create an account. Now if you already have a Google account, you want to connect to it. Simply click on Use Existing can count and created using Google, or you can go and create a new my adolescent account personally, I've made one using Google Gmail. It's way easier and they don't spam you with emails. Next thing you need to. Go into connect to an account which as we've said, we're going to skip for now. And finally, when installing, it may come up to this question right here where it cannot find or locate the get. So if you don't have the get already installed, simply click on download an embedded version of Git and it would download it for you. And finally, as a final step, it may ask you for for Mercurial, which we won't be using. There is no harm in downloading. It, will just not be using it in this course. So simply click, I don't want any Mercurial. Oh, okay, so when you finish installation, a window like this should appear to you the most. If you don't have this window, you should click on Create right here, and this window will pop up for you. So here is where we create our repository, which is the most important part of the whole version control systems repository is the backup of our project. So if you click here on browse, you can actually find the destination path. So if we go into browse, click on D, and look into our Unity projects, you can see that we have only one project right here, which is hello world that we've done in the previous section. So what we're going to do now is we'll need to go into Unity hub and will need to create a new project. And this new project, you are simply click here on new choose 2-D. And this will be the project of our current section, which is magic q, k, or magic Game Cube. Okay, you can name it whatever you want. But the most important thing is that you remember the location. So make sure you remember the location of your project to access it through the source tree. Go ahead and click on Create. And now we shall wait for the Unity project. Gaye, welcome back of just skip the entire installation process using the magic of editing. And now we're back into Unity and we have our project setup, which is magic Game Cube. And now what we need to do is we need to create a repository for it. So go back into source tree, click on browse, and look for the project. You should remember when, where you've put it and if you go into your Unity projects or wherever you saved it, you should have. Now, magic Game Cube, simply click on it and click on select folder. Now as you see the repository name as the Magic game cube. And you have the option here to either choose Git or Mercurial. We are going to choose get. And here is where you can create a repository on account. As we've said, we will not be hosting anything. So simply uncheck it, get and click on Create. Okay, it will ask you problem with destination directory. Don't worry about it. Simply click on Yes. We wish to continue. Excellent. So now as you can see, we have this weird things around here and we're not sure what's happening. We have these assets, these libraries and so on, and a long list of things that are called onstage files. You don't need to worry about this right now. Simply go ahead download source three and install it. And this is actually your challenge, which is download and setups or S3. So go ahead and download source tree. Go ahead and install and set up everything. And I will see you in the next video. 6. Setting Up The .gitignore File: Welcome back everyone. In this video we are going to be ignoring some files. And we'll learn how to get all the files that we need to ignore it and put it in a folder that's called Git ignore. We'll also add a cube. Yes, No, actually it's a magic square, but we'll call this magic cube, will add it to our scene, and we will be creating our first commit. So let's get started. Now, if we click on our project, it opens up pretty fast, relatively fast. And while we, okay, so now it's open. And if we go to our source file, we can see that we have this temporary file right here and we have this library file right here. So let's go ahead and close out project. For closer, we can see that the temporary folder disappears. And if you delete the library folder, you can still open the project and unity actually rebuilds the library. You can try this at home. Don't worry, it's completely safe. Library contains cached information that helps Unity open up project faster. But the problem is we do not need to save this library in our repository. As you can see here, we have a lot of staged files are arming on-state files that are currently flow from library and they are useless. So what we want to do is we want to ignore them whenever we stage our files. So to do that, we simply right-click on any one of them. And you can see we have this ignore option right here. If you click on it, we have to ignore exact filename. Ignore all files with this extension. Or we can ignore everything beneath a library, and this is what we need. So simply click on this button and click on OK. And now all of our library, everything under Library is ignored. And if you scroll to the top, you can see that we have a folder here, a new folder that this dot git ignore what's called gitignore. And you can actually double-click on that and it will open in a notepad, you can actually access the information. And here you can see that we have library. And this gitignore file contains everything that will be ignored whenever we create our repository. Now another thing that we need to take into account is that we will be ignoring a lot of other files which are useless and will only take up more space and our repository. And how did we find all of these files? Well, thankfully, we have something that is called a dot git ignore file that somebody has created already knows what we should be ignoring. And you can find that. If you simply go into Google and right here, 5p and Git ignore unity and this search results should come up. Simply click on the one which is on GitHub and it should be the most recent one. It should take you to a window that is just like this. So scroll down and here you can see everything that we need in order to ignore and added to our dot ignore file. So simply highlight everything in this. Select All of it, click on Copy or simply Control-C. Go back to our taught ignore notepad, select everything and paste. And now we have r dot ignore file set up. Simply save that, were using control S. And now everything in the dot ignore file has been saved. Let's exit that. And now if we click on Git ignore, we can see that all of our files have been saved. Let's quickly go over the steps again. So first thing you need to do is to find a file here under Library and right-click on it, go to ignore, and click on, Ignore everything beneath. But here it should be Library. When you're done with that, go into Google, search for Git, ignore unity. Click on the first search result which is from GitHub. Way better. Go into GitHub and you should find this file. Simply copy all of that. Go back into source tree, select the gitignore file up here and paste everything inside of it and you should be done. Next thing we're going to do is we're going to create our first complet. So how do we do that? Go into our onstage files, which should be right here, and click on stage. All it will wait just a bit. And now all of our files us out are staged. To continue, we need to name this commit. And as a courtesy to our project, we always start with our initial commit by naming it. Initial comment a bit anticlimactic. But whenever you want to name a commit, it should reflect what you should reflect the changes that you've done to your project. So click on Commit. And now we have this branches right here, and we have the master branch, and this is our initial commit. Excellent. Now we have a backup to our project. So whatever changes we make to our project, we can always go back to our initial commit. And if we broken the project, we can simply fix it with the click of a mouse button. So next thing is your challenge. Your challenge is to setup the dot git ignore file. So you need to create your first 2D project in Unity hub. You need to create a repository and source tree for the project. You need to ignore all library folders and to create your first comment. So go ahead and do that. And I'll see you in just a bit. Okay, so welcome back. Here we will enter our magic cube, a project. Let's go ahead and go into that. Wait for it to open. It should open pretty fast. Okay, so Let's go ahead and do something right here, will simply go into our assets up here and we'll maybe create something. Let's see what we should create CO2 sprites. And let's simply create a square. We'll call this square of magic cue. And Now we'll simply drag it into our scene. And now we have a magic cube in the middle of our scene. If we click on w, which change, changes the one of the keys right here, we can simply lift that up and settled in the 0 position or go ahead and reset the transform and set it right here. Control S to save everything. And now if you go back and source tree, you can see that we have uncommitted changes. So click on uncommitted changes. You can see an on-stage files that we have something we've added an asset manager cube PNG here.me is something that unit uses and it was added and we've done some changes to the asset scene, sample scene. So stage all. And now we can click here on commit on the top left corner. We'll call this added the magic cue. Click on Commit. And now everything saved GO back into master. And you can see that we have an initial commit and we've added the magic cube. Excellent job. I know this may not be very cool, but trust me, this is a fundamental skill for when you become a professional game developer. And I'll be seeing you in the next video. 7. Print Using Debug.Log(): Welcome back everyone to another amazing video. In this video we are going to be printing things to our console, but not using print, but using debug dot clock, which will enable us to add warnings and errors. And we'll do that using a script that we've created in our project. We'll be adding it to our magic cubed. So as you can see an inspector, we have this script attached to it right now and will be creating some code who very scary, but not too much. And finally will be committing our project. So let's get started. Okay, so first thing you need is this console window. If you don't see it just yet, you can simply go into window and go into our whereas it, so it's in general, console. Simply click on it and you should get this console window. It will be up here somewhere. You can simply docket next to our project. Okay, great. If you look closely, you can see that we have clear, clear collapse. So clear what it does is it clears all of our console. I've checked it on clear upon play. We have colored, which means that when we have suffered all messages that are the same, it's simply collect, collapses them into a single message. And here on the right, we can see that we have three buttons that we can check and uncheck. One of them is messages, the middle one is the warnings. And on the right we have the errors. That's the scariest messages we can get. Okay, great. So next we're going to create our C-sharp script. You are already familiar with it. So go to our project, right-click. Go to Create and click on C sharp script. Whenever you want to name something like this, make sure that you name it correctly the first time we've talked about this. So what are we going to name it? Let's simply name this Q. Click on enter. Now we have our cube script. Excellent. So we can open the sub by double-clicking on it. And Visual Studio will compile, waiting for it. Anytime now, loading solutions. And we should have everything in. Oh, okay, great. So as you can see, we already have some code and here we don't want to be worrying about that. What we will be doing is we'll go into our start method. And inside we're going to be printing to our console. Now, if you went through the first section, you may realize that we used print, but now we're going to use debug. And as always, Visual Studio is extremely helpful. So DBA Debug, click on Tab, it will finish it for you. Dot log and open up the brackets. And as, as I've said. Previously we've used print, but now we're using t Bach. Why is that? Well, debug gives us more flexibility and control. And it's technically butter, and it gives us better habits for future coding. So what is the message we're going to write in here? The message will be hello, everyone. Every one. I'm printing from Debug. Ok. Put this semicolon there, and now we save it, puts a Control-S, go back into unity. But now if we click on play, we should not see anything. And why is that? We only see r square and the scene, but nothing is printing to the console. That's because we haven't attached our script to anything. So let's go ahead and attach it to our magic cube. Save that. And now when we click on play and go into console, we should have Hello everyone. I'm printing to debug. Excellent. Okay. Now it's time for your challenge. And you will need to add a couple of lines. So first thing, you need to add two messages that display on the console battling too, the player to press a certain arrow key. Next, you'll need to add one warning message. And finally, you will need to add one error log message. And hour. I'm going to be a bit helpful with you here. If we go into Visual Studio, I will give you a hand. So if we click on debug dot log, we can see that we have log error and log warning. So go ahead and ground that challenge. Welcome back. How did you do that? It's not a very hard challenge, but it might be tricky if you're just starting off. So let's create our debug dot log. And we'll change this here, will tell the player. If you press the up arrow, you'll jump. And below we're right. If you press the right arrow, you'll move O, k. And now we'll need to create a warning. So let's go ahead and do that talk clock warning. And simply when you open the brackets, you can click anything. If you press the space, nothing happens. And finally, our error, which will be debug dot log error. And inside of it, what should we write? If you smash the keyboard, nothing happens. You just cry. Case. Save that key, keyboard, keyboard, okay, nothing happens. You just cry, save that, go back into Unity. Everything should be compiled and if we click on play, hello, okay, great. So if you press the up arrow, you'll jump. If you press the right arrow you are move. And we have a warning that if you press the space, nothing will happen and an error. If you smash the keyboard, nothing happens. You just cry. Great, I hope you enjoyed this. Oh, and one last step. Click on play, save everything, go into source three because we have uncommitted changes. I don't think I'll be doing this every single video, but you should know that whenever we make changes to our game, we should always commit DM stage all. Click on Commit here on the far left corner. And what should we call this? We'll call this adding a script with the bulk, the bulk dot Log Insight. Okay, great. Commit that. And we have it in our master branch. And I'll see you in the next video. 8. Variables 101 : Welcome back everyone to another video. Today we are going to learn about variables. So we'll learn what variables are. We'll learn how we declare those variables. And we are going to learn how these variables make our code more flexible. So as you can see here, we have some different kinds of messages because we've integrated those variables into all the backlog. And here in our code we see that we have three new variables. One is integer and the second one is a string. And we have also a lope. And we've added those variables into our debug dot log. So let's not waste any time and let's get started. So variables, what are variables? Well, we can think of variables like boxes. You have a box that we call lives, and we want to put some information or something inside that box to hold it. So we put a three inside of it. And what is that three while it's an integer number. How do we write that in code? Well, we have this way of writing it. It's an N2, which means an integer lives equals three. But what do these even mean? Well, first of all, we have the type of the variable. We have the type here is integer. We have the name of our variable, which is Lives. And by, while it's a common tradition encoding, if you like, of naming the variable where the first letter will never be b capital, and all other words inside of the variable name will be capitalised. And finally, we have the data and the data should reflect the type that we give it. So what other types do we have? We have float variables, for example, if we want to talk about velocity and velocity has can be 4.8. And the way we write it as we write float velocity and 4.8 F, whenever we want to make a float variable, we add to the end of it. And then we have Boolean. And as you can see here, we've named it is that we're the first word of is not capitalized, while the second one is capitalized. And the bool or a Boolean can be either true or it can be false. And we also have a String variable. And string valuable means that it has, it's a string of characters. Or for example, here we have the box called my name, as you can see also, the second word is capitalized. We write string name equals Michelle, which is me. And we put it inside of a box, and now we have a variable of strewing. Okay, great. So how are we going to translate that into our personal code? We're gonna make this, well, what actually happens is valuables make our code more flexible. They help us. Manipulate the code in a better way. Let's demonstrate that. Let's go back. Let's go back and to our Visual Studio, and let's go ahead and create a valuable. So first thing first, if we create a variable inside of start right here, we can only use it inside of start, but if we write it outside of our start method, we can use it anywhere we wish in our code. So let's do that first. So what variable should we use? Well, let's create an integer variable. So let's say that we have an integer, will name this integer number of times, and we'll assign it a value of, let's say five. Okay, save that. And as you can see, it's black and white or it's a bit transparent. That means that we still haven't used and now let's use it. So if we go ahead and debug dot log, it says if you press the right arrow, you will move. So let's go ahead and add something to it. To add a variable, we simply do the following. Click on space, close the bracket or the little column in here. And then we write plus, we write number and Visual Studio. As always, this is our best and helps us simply click on tab at finishes, and we save that. And now we have a variable inside of our debug. Let's see what happens and visuals. I mean, in Unity. Let's go ahead and clear all of this and click on play. And as you can see here in our message, if you press the right arrow five, you'll move. We should have added five times, but you get the picture. So now let's add a string variable. So let's go ahead and click right here. String will name this name of the KI. And our string will be, let's say space, space, space. And now we want to add it to the warning for example. So instead of writing space here, will simply open this and close it on the other side, right? Plus and name of the key. And then another plus. And now we have a string variable inside of our log warning. We save that, go back into Unity. And when we click on play, we should see here that it's space. Well, that wasn't very helpful because we don't know if it works. So let's change this from space two. And let's make this also or capitalised, save that, go back into Unity. Click on play and this should change to enter. And it did. So you can begin to see how flexible using variable makes our code. So instead of going and looking for every single name, we can simply add a variable and change it from the top and all subsequent uses of it and our code will change. So what now? Well, I think you know, because it's time for your challenge and your challenge is to create your own variable. So you need to create a variable of type string and use it inside the, inside of the debug.org, which we already did. So go ahead and make your own variable. We are going to create a variable of type integer and use it in one of the warnings. And finally, we're going to create a float and use it inside of the error logs. So pause the video right now and go, try and do your best. Don't worry about messing things up. That's why we have version control. I'll see you in a second. Ow, kay, welcome back. So how did you can on was that shouldn't be too hard. So let us go ahead. We've created our string, we've created our integer. Now it's time for our float variables. So let's go ahead and create a float. What should we call this? We'll call this at a speed, will simply call this speed. Speed of breaking. And we'll make this value 4 or weight will make this 6.94. Oh, okay, great. And I've made a mistake here. It should be 6.94. Okay, so let's go ahead and add it here and our debug dot log error. So if you smash the keyboard, that's gonna look here at a speed of, let's simply add this. And what should we write here? Speed of breaking. Click on another plus. And now if we go back into Unity, collect on Play, it should tell us that if you smash the keyboard at a speed of 6.94, nothing happens. You just cry. Okay, I hope you enjoyed the video. I know that the variables and the messages in the debug log don't make a lot of sense right now, but you will see that later on. It will be very important. So I'll see you in the next video. 9. Responding To Player Input : Welcome back, my fellow game developers. In this video, we are going to be responding to our player's input. And that will happen. How well click on play right now we don't see enemies messages until we press the up arrow. It give, it gives us a message that tells us up arrow key was pressed. And if we press the left arrow tells us laughter, okay, got pressed, right arrow and the down arrow, and we did that using, using some magic code rule. Very scary, but don't worry about it. I will take you step-by-step. And in fact, in this video, you are going to do that, not me. So let's get started. Oh, okay, so as the title of this video suggests, we are going to be getting our player's input. And for that we'll use, for example, the up arrow, right arrow or the left arrow. And based on that, we are going to print something on our console. But in this video, we'll be doing something different. Because my goal in this course is not to just show you how to create a game. I want you to be come an expert problem solver. So in this video, I'm going to tell you the problem that we have. And I will take, take you step-by-step on how I usually solve my problems. So first thing we're going to do is we're going to think about problem. So the main problem is we need to get our player's input from a certain key that he pressed. He or she of course presses. So the keywords to look for our input and key. And whenever we face something that we don't know, unity has a great documentation site. So we can actually Googled. So we go in to Google and we simply write input. Unity will get all these search results. But what we are looking for is the documentation which is scripting API input unity. Click on that. It takes us to this documentation. So we see that we have input, we have the scription. You can always read all the documentation, but of course lead it, read it later. You don't have to get specific in every detail, just a glance over to see what it has. So as we scroll down and we know that we need a key that will tell us what key the player pressed. We can see that we have multiple static methods in here. And one of them is called get C0, which returns a true while the user holds down the key identified. Now, as we said, our problem is, doesn't consist of a player holding down achy. We only want to return something or get a response from the play, from us, from the game. Whenever a player clicks or presses a button doesn't hold down. So if we read below it, we can see that. Return true during the frame for user starts pressing down the key identified by name. This looks like something we could use. So we click on get keydown and it takes us yet to i another Unity documentation. And here is where we begin to read our description, which says that it returns a true during the frame, the user starts pressing the down identified by name, caret. This is what you need. And even if you're if you don't know how to actually code it, if you scroll down just a little bit, you can see that we have multiple examples of this. And here we have this amazing example which tells us that they are actually putting this get Qi Dao inside of Update and using something weird, which is an if with some parentheses and I don't know what that is. It's so weird, it's so difficult. Let's not trouble our heads with, let's simply copy this. So we'll copy this. And of course we'll be explaining if conditions later. And we go back into our Visual Studio. And as they told us in the example, we will paste it inside of update. Oh, okay, great. So a small x, I do a small explanation of what we're actually doing here. So if condition works, as it says, if anything inside of this place here, inside of these two brackets is true, we will execute any code inside of these two curly brackets. Don't worry about if conditions, if you're new to them, will be explaining them in more in-depth in later videos. But for now, paste this inside of update, save it, and let's go back into Unity. Click on play. Now we press the space bar. Space key was pressed, pressed, pressed and pressed. Oh, okay, girl rate. But as we've said, we are not looking for the space. We are actually looking for the key arrow. So how are we going to do that? Well, we hope that our good friend Visual Studio will help and it will. So if we double-click here on space and delete it, and delete the little point. And if we click it again, as we see, it gives us a lot, a lot of options. So what are we looking for? We're looking for the up arrow. So let's write Arrow. And voila. It gives us all the options that we can use. And one of them is the up arrow. So simply click on tab and now it should work when we press the up arrow. So let's remove this and actually instead of space, we write up arrow. Oh, nope, not. Excuse me. So save that. Let's go back into Unity. Oh, go back into Unity, clear all of that and click on play. Wait for it to compile. And now if we press the up arrow, we should get up. Arrow key was pressed. Oh, okay, great. One more thing I want to do. Let's comment all of these out. And the way we do that is with two backslashes just as we have comments in here. Just so they don't get in the way. And now it's time for your challenge. And your challenge is to finish the rest. What do I mean by finished the rest? Well now you have to finish. If the player pushes the down arrow. If the player pushes the left arrow. And a small extra challenge for those of you out there that are very motivated if the player pushes the spacebar, even though we've already done it, I want to see how you do it. So pause the video right now and get on with the challenge of gaye. Welcome back. How did you get on with that? So let's simply go ahead and copy this. There is no shame in copy-pasting code, even though it's better to find a better way to do that. So what will we be using? And here we'll be using the head down arrow. And we'll copy this also and save ourselves as much time as possible up, down arrow. And in here we're going to use the left arrow. Also copy that. And just for the sake of being even extra, nerdy will make one for the right arrow. Right arrow. Copy that. And here we are simply right arrow. Let's make this capital letter save that. And now if we go back to Unity and click on play, all of this should clear. And now if we press the up arrow, we get up arrow key was pressed. Left arrow, left arrow key was pressed right and down. Everything is working fine. And before we go, don't forget to commit our changes. Don't worry about if I have some extra changes here. These are just experiments. So stage all. Click on Commit and we'll write here, added a couple of layer inputs. Okay, so comment that everything is working fine. It's an hour masters, and I'll see you in the next video. 10. Adding Rigid Bodies & Colliders : Welcome back my friends to a another video. And this one will be using rigid bodies and we'll be using box colliders. What, how are we going to use them? We'll use them adding components. And why are we going to use them? Well, because now our cubes are not just images, they actually fall. And not only do they fall, but they get caught using platforms that we've created. So Let's not waste any more time, and let's get started. So now, if we click on play, our Cube doesn't do anything interesting. And what we wanted is we want to at least make it for. So how do we make this cube fall? And hence, how do we add gravity to it and make it a physical real object? We do that using a rigid body. And what is a rigid body? Well, rigid body control allows us to control an object's position through physics simulation. No, it's a handful. It's big words. But if you go to a unit is documentations which I've left you and the resources you can actually read all about rigid bodies. And rigid body object will be pulled downwards by gravity without adding any code, which is amazing and exactly what we need. So, so if we go back into Unity, we can actually go into our magic cube. And if we look here on the right to our inspector, we can see that we have a transform, we have a sprite renderer, and we have the cube. So transform tells us the position that r cube is at. The sprite renderer actually renders our cube. So if we turn it off, put, it goes away, turn it back on, it turns back, and the cube is our script. So let's make all of these smaller. And we have here this button which allows us to add components. So if you click on add components, we can actually search for rigid body. And we have two rigid bodies. One is rigid body, which is used for the 3D world. And the rigid body that we will need, which is Rigid Body 2D. Click on rigid body to d. And now we can see that we have a lot of options and information and constraints and body type and Mass. Don't worry about all of these. We won't be using all of them. But if you are interested and you want to go deep into the rigid bodies object, you can read all about them in the Unity documentation. One thing I will be glancing over is the dying body type, which we have dynamic, kinematic, and static. Now, later on we will delve even deeper into these three. But for now what you need to understand is that dynamic is when our body is subjected entirely to the physics world around him. Kinematic as when our body is not affected by gravity, but could be affected by other forces and static as an object that does not move at all, whatever happens to him. So we need r cube to be four now, dynamic. So we've added a ridged body. Let's save that. And let's click on play and see what happens. If we click on play, what are her belt D or our magic cube goes down and leaves are seen and we have no idea where it went. It goes away into Arno, what's called down there, maybe help or anything. But it disappears. So how are we going to hold it? Because for now it's not that magic. We'll do that using colliders. And what our colliders, What is a collider? A collider makes it possible for objects to interact and hence collide with each other. So whenever our Collider or, or whenever our body has a collide and it touches a another body that has a collider. They will collide and stop each other. We'll use it to catch objects that are falling, are falling because of gravity. So we're going to use this collider in order to catch the object that we have. So let's go back into Unity and close down this rigid body and adding another component. And we can actually search for collider. And as you can see, we immediately have tons of options. We have box colliders, we have box colliders to the capsule, capsule to the circum, circle to the So, because we're using R cube or square, will be using a Box Collider 2D, which is ultra simple. And as you can see, we also have tons and tons of options. You can read all about them. I of course, lifted and the resources. But one thing we need to focus on is this is trigger, and this will be useful later on in the course. But for now, let's just zoom in and see what we have. We can actually see our box collider. It's green. It's a green line all around our box, but we cannot see it right now. The way to see it is if we click here on the edit collider. And we can actually make this collider bigger, make it this way, and this way, and actually make it outside. So this is the collider is, this is actually where our object will be colliding with objects. So let's reset all of that. And let's see what happens if we click on play. So exciting. And then o, nothing happens. Why is that? It's because you have a challenge and your challenge is to catch the falling a cube. Don't worry, I won't leave you alone. Because first of all, you need to create another cube and size it to platform size. What do I mean by that? Well, you need to make our platform from this end right here all the way to the other end in order to catch our queue. So that's continuous with the, Hence create a another cube and make it a platform and a rigid body. And don't forget to change the rigid body type two, static. And finally add a collider to our platform and catch our cube. So pause the video right now, give it your full attention, give it your full concentration. And don't worry about making mistakes, because mistakes are the best part of learning. You. Either you do something well. Or you do it wrong and learn from it. So take your time and do the challenge. Okay, welcome back. How did you get on with that? I hope you didn't just stare at the screen for like five seconds until the video continued. Okay, so now we take our magic cube and what we'll do is we'll duplicate it. And we can duplicate it in two ways. We can either right-click on here and do CO2 duplicate, which will create a another game cube. Or we can simply click on Control D. And now we have another cube. If we take it here below, Let's make this cube a little bit bigger. And the way we're going to do that is by scaling it. So here we have the scale in the x direction and we have scaling in the y direction and in the zed. But because it's Tuesday at one scale anyways. So let's bring back Y 21. And let's increase the x scale until it fits between the two sides of our game. Now we have a platform, and let's differentiate a bit between them. So let's make this platform a bit darker. We can change the color in our sprite renderer. Here we have the color. And if we click on it, we can make it a bit grey or black ish. So let's make it black and will make the square here. Let's make it the, keep it white or make it a bit grey. Let's see, maybe let's just keep it white and let's change the background. Ooh, very fun. So we can go into camera and actually change the background color, which will make Gray o case seems great enough. And let's lower this magic cube actually, let's change its name to the platform. Oops, right? Platform. And now we have our platform that's lower this down. And these are the edges of our camera. So now if we save that and oh, I forgot something and good thing I remembered. We click on platform and don't forget to make this static or else it will just fall away, fall down into whatever down is. Click on play. And hopefully, yes, it holds. Amazing. I hoped you liked the video. I hope you did everything and commit everything we've done. So committed. Add it. Well, actually made my magic cube fall and held it with a platform using rigid body and colliders. That girl rate. So stage all comment, and I'll see you in the next video. 11. Adding Magic To Our Cube: Welcome back guys to a brand new video. And as advertised in this video, when we click play, our q becomes magic. How's that? Well, if we press up, he jumps. If we press left, he goes left. If we press righty goes right. And if we go up, up, up, up, we can actually press down, down, down, down, down, and make him come back faster to Earth. So let's get started. Okay, so first thing we'll do is we need a reference to our rigid body. What do I mean by a reference to our rigid body and why do we need it? So reference to a rigid body means that we'll write up here public and don't worry about public will explain that later. But for now, public means anybody can use it. So public, rigid body, it's a variable of type, rigid body. And we'll call this my Rigid Body 2D. Okay, save that. Now, how are we going to tell us that it is the rigid body on current object? Well, if we go back into Unity, clear those messages, pesky warnings. And if we click on q right here in the inspector, we can see that now we have an empty slot for a rigid body. So if we click on the little circle to the right, we can see that we have the magic cue or the rigid body of the platform. So let's go ahead and click on the rigid body on our queue. Double-click on that and say that. One thing I noticed is that if we click on our platform, oh, it's actually, we made them steak. We shouldn't add the rigid body. In fact, we should remove the cube. So let's remove the cube component from the platform because we don't need to move that. Something we should have done in the previous video. But that's no problem. Go back to cube and now we add a rigid body which is magic QP. Excellent. So save that. Now we have a reference to our cube. Next thing we're going to do is we're going to add velocity to our rigid body. So if you went through the documentation of the rigid body in unity, in Unity documentation, I think you have noticed or maybe you didn't, but there is a component or how do we call it a property and my rigid body that we can use in order to manipulate the velocity. So now our arrow keys no longer print things to the console. Our arrow keys now actually manipulate the velocity of our rigid body. So let's do that. So in order to access the velocity, we will write my Rigid Body 2D, which we now have a reference for dot velocity. Velocity. Now, if we glance over velocity, we see and actually Visual Studio tells us that it's a vector to what is a vector too? Well, a vector is a vector in to the space. So that means it has the x-coordinate and the y-coordinate. Now you should be pretty familiar with X and Y coordinates from school. It's not too hard of a math, but it should be. Now, I will of course, leave some resources in the video attached to this video where you can check out everything about vector tools. Don't worry about it. It's pretty simple to create a vector two, we only need to do is write new vector two and open the brackets. Nothing too fancy. And inside those brackets we can actually go through multiple parameters that this vector two can take. And it takes a float x, float y. So how do we want to move it? In our case, we are pressing the up arrow. That means we want the box to move upwards and not move to any site to site. So how do we do that? We simply write 0 f in the x-direction and ten F in the y direction. So can add means it's a flow because our parameters told us that the rigid body takes floats. So let's go ahead and continue the down arrow. Now, even though Down Arrow, I don't think we'll be needing it, but for practices, practice, practice reasons, we are going to add it and being this is down, instead of ten, f will make this minus ten. So save that. Let's go into Unity and see if something actually worked. So click on play. R cube falls to the ground and if we press the up arrow, he actually jumps and then falls down. So up, up and then down, down he falls faster. Excellent job. And now you know what time it is. It's time for your challenge. Complete the magic. So you have to finish adding velocity using the left arrow, and then you need to finish adding velocity using the right arrow. So pause the video right now. Go ahead and do that. Challenge. Welcome back. How did you get on with that? I hope everything went well. It's very easy that simply copy that. And now when we add it to left, we will have 0 in the y direction and we will add minus, let's say ten. Let's keep it them. And in the case of the right arrow, will add ten AF in the x directions direction and 0 in the y direction. Go back into Unity can lack on play. And now a free press on the left arrow. We should move left or right arrow and move right, up, up, up, down, down. Everything works perfectly fine. Final step, as always, I don't think I will keep doing this, but for now just to get you in the habit of doing it. So assets, what should we call this? Well, made my cube move left, up, down, and right based on the arrows, put an exclamation mark. So comment that I'll see you in the next video. 12. Using If, Else If, Else Statements: Welcome back everyone to another video. As the title suggests, we are going to be learning about if conditions and we are going to learn how we can manipulate them. So if we click on play right here FOR box moves to the left, our console prints that are cubes out of bounds to the left. And if we move to the right, it tells us that our cubes out of bounds to the right side. And the best part is if we jump, it tells us that our cubes out of mine bound to the upper side. So how are we going to do this using if statements? So put your concentration caps on and let's get started. So before we start, let's talk about what if conditions are, why we use them and their structure. So conditionals, if statements, they are, as the name suggests, they are called that we execute only under certain conditions. So this is the structure of an if condition. We've used it before and our arrows in player inputs. So if some condition that needs to be true is true, we execute whatever code is inside these curly brackets. So if we put in a Boolean, as we've said, a boolean can either be false or it can be true. So if that Boolean is true, we execute the code that is inside the curly brackets. Now if this statement happens to not be true, we will simply just avoid or not even considered the worthy, if, not even consider the code inside of the if statement. But if we add another else, if and as its name suggests, is if the upper condition does not, is not true, we check for a second condition, which is some other condition that is true. And if that statement or condition is true, we execute the code inside of these curly brackets. And if both statements are false, then we finally use something called Else. And this does not have to be, nothing has to be true in order for the scope to be executed only all over. If conditions above it should be false. And we've used this else if condition before. We've used it in our code when we tried to get the key down from the player. So how does this exactly work? Let's zoom in a bit. So input, this input, which is a class and unity, uses the function or method, get key down. So if you hover over the guessed key down, you can see that it's a boolean and it returns a true during the frame, the user start pressing down. So whenever our player presses the up arrow, as we've used, as we've said, told it here. And we did it using key code, which is a another function in Unity, dot up arrow. If he presses these, the up arrow. It tells the get keydown that this, during this frame, the up arrow key was pressed and it returns true. That makes our cue, that makes this code right here Execute and moves our cube. And the same is true whenever we use the other if statements. So now what we're going to do is we're going to be creating our own if condition. And we are going to do that in our case for the game. So for now, if we click on play and remove our cube from side-to-side, whenever he gets out of boundaries, he falls down from our platform. And what we want to do, first thing, we'll make our platform just a little bit bigger. So will increase its scale. Make it just a little bit bigger to give our cube a place instead of just falling into whatever down is. And now we are going to check for the coordinates on this cube. So this white frame right here is what our game actually sees. And if we lock our game view next to our scene view, oh, and as you can see, it gets smaller. To fix that, we can simply go into gain and click on this right here and simply make it into 16 by nine. And this should always keep or frame at the same dimensions. So now if we go into our scene, let's make this a little bit wider and click on our game queue or magic e cube and move it. You can see at the top right and the inspector that the position changes. And this value can actually be accessed. So whenever our cubes goes outside the boundary. So let's say it should be right about here, which is 9.42. So whenever it goes outside the boundary, we want to print something to our console. And the same holds true whenever we go to the other side, which is what should be 9.40, we'll settle for 9.5. Okay? So how are we going to do that? Well, using the structure of if conditions that we just learned. So let's go ahead and save this and go back into our Visual Studio. And we'll do this inside of object. So what are we going to do? We want to check if the cube has moved outside the right boundary. So if should we write here, first thing we'll need to do is access the transform of our cube or game objects. So its transform, simply write transport dot position. And we're not looking for any position. We are looking specifically for the x-position, so it's X. So if Transport dot position, dot x is greater than 9.5 f, because remember it's a float. Then inside of the if statement, we want to execute some code. And for now we're simply going to print out to our console. So we're like debug. But log, let's make this a warning just for fun. So debug dot log warning. So we should write something inside of it. Our cube is out of bounds. To the right side, was two exclamation points to make it a bit more dramatic. So save that. Go back into Unity. Wait for it to compile and understand what is happening. And now clear all of that. Click on play. And now if we move to the right side, as you can see, our cube is out of bounds to the right side. And the more we move, but if we move to the left and nothing happens, so pause that. And now we'll make a, an else if statement. So else if. And then side of it. For our else if statement, we're going to check if our cube goes to the other side of our screen. So it's transform. Again, we access the position and we need only the X. And now we are going to check if it's smaller than minus 9.5 f. And in this case, we're going to also print a warning, which will be our cube is out of bounds to the left side with two exclamation points. So let's make this a little bit neater. Control S to save all of that, go back into Unity. Wait for it to compile, clear everything. Click on play. And now if we go to the left side with r cube, it tells us that our cubes out of bounds to the left. And on the right side, it tells us that our cube was out of bounds to the right. But now if we jump without cube, nothing happens because it's time for your challenge and your challenge is to finish the last if statement. So finish if statement when our player goes out from the top of our screen, and I'll give you a couple of hints, will need to move the cube around in our scene and understand the top boundary. And we'll also need to use the if statement to print to our console. So pause the video right now. Take your time with this challenge. I'll see you in a bit. Okay, welcome back. So let's clear this up and let's see our upper bound. So if we move our queue and we can see on the right here that we have the y position changing. And if we take the y-coordinates and check for them at about 5.5 r RQ leaves the camera view. Okay, great. So let's go back into our Visual Studio and write another else if statement and else if our transform dot position. And now instead of the x, we're going to be using our y. So if our transport dot position dot y is greater than 5.5 f, we will print another warning in here. And this warning, our cube is out of bounds to the upper side, also the exclamation points, save that, go back into Unity. Let's wait for it to understand what we've done. Click on play. And now if we jump, jump, jump and we get out of bounds, it tells us that our cube is out of bounds to the upper side. Okay, so final step, let's move out of play, go back into our source tree, and now we can commit everything. So stay Joel, click on Commit and we'll call this adding if statements to my game. Click on Commit. And I'll see you in next video. 13. Public Methods & Return Types: Welcome back everyone to another video. In this video, we are not be doing a lot of coding, but we will be restructuring our code. How are we going to do that? Well, as you see, our update method is a bit different because we extracted all of the things that are related. So for example, now we have a method that is moving our cube and it's right here. And we have a another method that is out of bounds. And our printer, not only that, we've also created a public method which is printing from outside, which also has a parameter. So exciting. And it returns a string and it's used not inside of cube. It's used in platform, a new script that we've created. I'm so excited for this video. I hope you are too. So let's not waste any more time. Let's get started. Okay, so if we look right now at our start and update methods, we can see that they are kind of cluttered and there are things that are not related to each other. So for example, we have all of these if conditions that relate to our cube movement. And we have them right next to the if conditions we've created to understand the boundaries of our queue. So we need to restructure them in a way and to make it look more appealing to the eye. So we're going to do that using methods. So what our methods, well, method structure are kind of like this, just like we have the start method and the update method. We can also create our own math. And they kind of look like a valuables, but they are also kind of difference. So we have V2, first of all, is the access type, and this is the accessibility. So we have to access types. It can be either private or it can be public. And we're going to use both in our project. So private is when a method is only used inside of its class. So for example, if you create a public method inside of cube, only cube can use that method. But if you create a public method, other scripts can use your method. Also. Then we have the return type, and for now we've only used the void, which means that we return nothing. We can have a return type of integer, for example, where a certain method returns an integer, it can also return a string and it can return other things. We also have a method name. So the method names should always reflect what the method actually does. And as a convenience, just as we name our variables, the first word will all always is not capitalized when we are naming methods, our first word is always capitalized and all subsequent words are also capitalised. And finally we have parameters and we have a one. A parameter has nothing inside of it. That means we pass nothing. And what parameters are? They are like variables that we pass to our method and we can use them inside of our method only. So how are we going to use these methods structure? Well, we're going to use it inside of our code right here. So let's begin by restructuring some things. So as an example, I will show you how much more efficient our code becomes. So let's remove all of these comments right here. And as you can see that every time we would need to comment these debug logs, we need to go and do them one by one. Well, we can actually use all of these if you highlight them. And of course you're using Visual Studio and you right-click on them. You can see that we have something up called quick action and refactoring. So if you click on that, tells you if you want to either extracted to a local function or extracted to a method. So if we extract it to a method, and by the way, the difference between a function and a method, you can actually use them interchangeably and however you want. But functions are usually methods that are inside of a, another method. But a method is a method that is outside the method we're currently doing. So it's a bit confusing. You can use both of them interchangeably. Don't worry about. So what are we going to name this method here? And we are going to call it printing to our printing equal weight to our console. And click on and turn. And now we have this function or method right here. And as you can see, it's a private method that doesn't return anything because it's void. And now if we want to comment that out, we can simply comment this function out and all of it is commented out and at 1P printing to our console. So this is the first benefit of using methods. So let's go ahead and put this under update. So if we click on Control X to cut it, and we'll put it below update. I like to put update right below the start method to have a nice and cohesive structure to our code. Next thing we're going to do is we're going to extract to nother methods. So first of all, we're going to highlight all of the if conditions in our AP for our food, for moving our cube. So highlight all of them, a right-click, create a extract a method. We'll call this mass moving our queue. And we will also extract this method. And we'll right-click go to extract method. And we'll call this method, what should we call this? Out? Of bounds printer. Okay, so now we're sorry for the Get Back to zoom in on it. So now as you can see, our update method is very cohesive and it, uh, we can easily see what our update method does. So it is moving our cube And it out of bounds printer the checks for out of bounds. Whenever r cube is out of bounds, it prints something to our console. So now you can see that we have this method right here and another one right here. And finally we have the printing to our console. Excellent. Now we're going to create a second script and create a public method just to demonstrate how everything is working. So first thing we'll do is we'll create a public method just under update, and we'll call this, well, first of all, let's make a public we'll make this a void because we don't want it returning anything for now, public void. But we'll use it. We'll call this printing from outside. Okay. You don't have to make your method names that long, but just for the sake of giving an example. So what this function will do, it will simply print something or a certain message that will have Hello from the other side. I don't know what froms capitalised. It doesn't have to be. So it's Hello from the other side. Let's go back into Unity. Click on platform because it's the only other object that we have besides the camera. Let's add a component and let's create a platform. Plat form scattered. So New Script platform, excellent. Let's go ahead and create it. And it enough, but it should be added. And now if we, now we have it in our project. So double-click on it and it should open in Visual Studio. And as you can see, we already have the void update method and the void star. Now inside of start, we are going to get a reference to our cube script and use the public method that it has. And how are we going to do that? Well, we're going to do that using something called find object of type. An object of type has these two operators right here that we need inside of it to tell which script we are going to use. So it finds the object of type cube and Visual Studio always helpful. And now if we click on dot, we can see that we can use anything that is inside of the cube. So if we, for example, want to access the Start method, we can't. But if we want to present, as you can see, it gives us the printing from outside method because it is public, so free. Save that and go back into using Unity. And let's also save our scene and click on play. And before we do that, let's clear this up. And as soon as we click on play Hello from the other side, how cool is that? So we've created a function or a method that is inside of the cube, but we are using it inside over the platform. That is so cool. And this actually is the basis. And it's very crucial because we're going to be using it a lot in our game in the next sections. So your challenge is to create your own method. You'll create a simple method with a string return type. So instead of void, you will have it as a string type. You will also give it an integer parameter, and you will use it with the string and return it. So it's a bit of a big challenge, but I think you are ready for it. And a small hint use to string. And it will require a bit of research to understand and do the challenge. Take your time. Don't, don't be afraid of making mistakes as I've told you, trying and failing is not the end of the world. So I'll see you in a o. Ok, welcome back. So now we are going to change our method just a little bit. So instead of void will make this a string, and it currently doesn't take any parameter. So we'll give it a parameter which is an integer. And we'll simply name this integer value to not be over-complicate. As you can see right here, we have a squiggly red line. That means that our function is not working properly, properly. Why is that? Because it has a return type, which is a string, but it's actually not returning anything. So how do we fix that? Well, we need to write here return, and we need to return a certain value. And what that value is, well, needs to be a string. So let's go ahead and create a variable inside of our printing from outside. So this variable will be a string. We'll call this variable printing something. And what? We'll have it print, well, the value we were s_1 is. And now we can use this parameter that we've been sent from the other side. And now in return, we will return, print something and that trip fix our squiggly red line problem. But because we've given it a parameter in here where we call it from, should also give it a certain parameter. So we have to give it an integer. And that integer, let's say, will be a 4x4 or anything. Or you can even create a variable right here. We'll call it an integer. We'll call this value to sand, and it will be equal to say nine. And in here, we'll send the value to send save that this actually returns a string. So let's put it inside of a string reference, which we'll call string from L outside equals. And now we'll simply debug dot log and will be printing this string from outside. So close that, save that, go back into Unity. So clear everything. Click on play. And now the value we were sent is nine. Excellent job. And one thing I want to make clear is that because this is a string and this method returns a string, we can actually directly put it inside of our lock. Excellent job everyone. Hope the challenge wasn't too hard. I thought it was a little bit step up and it needs a little bit of research, but I hope you tried your best. And as always, before we go, we need to stage all comment. Created my first public method with a return type, commit that, and I'll see you in the next video. 14. Prefabs And Parent Child Relationships: Welcome back everyone to a new and very exciting video. In this one, we are going to learn about prefabs. And not only that, we'll, we'll learn about prefabs, how we can use them from scene to scene. Here you can see that we have a diamond was something called a polygon collider. We also have this magic cube and a small circle, but actually the circle moves with our cube because it is a child of that cube. We can also, we've also created a second level, level one and level two. Here we have three cubes, as you can see, and for some reason they are blue, and we'll see why they are blue. We also have in diamond right here. And if we click on play, all of them fall down, and that's it. So, so exciting. I'll see you in a bit. Okay, so what is a prefab? Well, basically it's a template for a certain game object. So if we created a game object with all its components and its script and its position, we can create a template from it to create other similar game objects. Ap system allows you to store a game object with all its properties. So let's say our periphery has a collider, it has a rigid body and it has a script. Whenever you create a prefab from set game object, you will have the same properties. And so why do we use it for? Well, we can reuse a game object configured in a particular way. We can edit many objects at once, and we can use the same object and different, different scenes, much easier. So let's go ahead and demonstrate these three uses. So creating a prefab is actually very, very, very simple. You, all you need to do is simply click on the thing that you want to prefab. So for example, we want to prefer our magic cube. Click on it and drag it into our project. And now we have a prefab of our cube. And you know, it's a prefab by looking up at the hierarchy and you can distinguish it by, because it's a bit more blue. Excellent. So now, what can we do with our prefab? If we click on it, you can see that it has the same properties as the cube in our scene. And now if we click on the prefab and jacket and to our scene, you can see that we can create three beautiful magic cubes extremely easily. And this is very helpful in many ways. So let's demonstrate how prefabs work. So let's say we click on this magic cube, which we see in the hierarchy is number one. So let's say we want to change its color. So if we go into our sprite renderer and choose color, and let's make it red. So now we have a red Magic cube. We save that. And you see that. Other two magic cubes are still white. And by the way, these cubes are called instant instances of prefer. And if you look closely in our inspector, you can see that we have a another tab open. So we have the open which opens our prefer, which has the magic cue. We can select the prefab and we can overwrite. And what this does. It applies whatever changes that we've made to our current instance, to our brief. So the things that have changed, you can see that they are also highlighted in a blue color right here. And we changed the color. So if we click on overwrite and click on apply, all what should happen is that all of the other instances of that cube changed to red and down here and our project, you can see that our magic cube is red now, that is very cool and you can start to see how helpful that is. So let's say we changed back, change back the instance to white. Let's take another cube and change that to green. So now, if we apply this to our prefab, What do you think should happen? Well, all of them turning green or will only the one that is the red turn to green? Let's try that, apply and ops, as you can see that only the prefab or that was originally, or the instance of prefab that was still the same as the original is changed to green, but the ones that we've also modified don't change back. So privet prefabs are a bit tricky, but they are very helpful. So for example, let's go ahead and delete those three cubes. And let's go into scenes and let's simply duplicate our current seen. By that we create a second scene. Let's rename this to level two. And our original scene will be level one. So now, yes, it asks you for preload. Simply click on yes. So now in level one we have these three cubes and then level two, apparently we also have these three cubes. So let's go ahead and delete them. Save that. So in level one we have the cubes. In level two, we don't have cubes. So what are we going to do about it? Well, instead of going to level one and duplicating or copying the cubes, we can simply go to our project and we have a magic cube. And we can add it easy as pie, right into our scene. And now we have a cube, a magic cube, and our scene. Okay, great, so that's a Prefab. Now, what our children well, let's go ahead and create go to assets. And to create a sprite. And the sprite will be a circle. So now we have this, let's say magic child circuit. Okay, so magic child circuit, we can go ahead and add this magic child circuit to our scene. And by the way, this magic cube is the prefab. This is just the sprite. By the way, we can also organize all of this. Or if we create a folder called this sprites, we can put both of these into sprites. We can also go ahead and create another folder called this scripts. And now we have these scripts inside of the folder scripts. And if we add another prefab, we can also create a folder for the prefabs. So now we have this magic child circle. Why do we call it the child circle? Well, because we are going to child it to our magic cube. And we do that by simply taking our magic child circle and dragging it right under our match cube, and now it's a child. Now what this child mean? If we click on the circle, we can move it as we always do. But if we click on the magic cue and we move it, you can see that the circle moves whether that means it is a child. And if we scale our cube, r, circle also scales. And if we scale in the y direction, it also scales if we wrote it. So let's see if we rotated. The circle also rotates and these are properties of a child grows with its parent. And the parent is magic cube. So it grows with its parent, shrinks with parent, it moves and behaves just as its parent does. And this is very helpful because sometimes we may need to add children. So if we have an object that has several objects inside of it and we want them all to move in unison. Instead of coating all of the children, we can simply coat things to the parent and the children will move with the parents. So we'll be using a lot of parent children relationship will be using prefab Also a lot. And now it is time for your challenge. And your challenge is to create a new prefab. So create a new object in our scene, whichever scene you want. Prefab it, make an instance of it in a different scene, and add a component to that instance. Apply the changes to prefab and see what happens. And if you want as an extra challenge, you can also make a child-parent relationship somewhere in our scenes. So pause the video right now and go do the challenger. Okay, welcome back. How did you get on with that? I hope that wasn't too hot. So let's take this cube, put it over here, or magic cube, which is square, ironically. And now let's go and go ahead and create something. So we'll go into sprites. Let's see, we'll create a diamond because diamonds are for diamond. Click on Enter and let's go ahead and put it in our scene. And we'll put it inside of sprites. Now we have a diamond classmates timeOfDay, but bigger. And let's change its color. So let's make it a blue, because diamonds are kind of blue, I guess. So now we have this diamond in here. And when we want to do is we want to. So what was our challenge? It was make an instance in a different scene and add a component to the instance. Okay, so we take this diamond and let's Prefab it. And now because we have two prefabs, let's create a folder, call this prefabs and everything is organized and meet. So now we have the diamond that is go ahead and save that. Go back into our level one scene and we have three cubes here, but now diamond. But we can easily add one from our hierarchy, super easy. So let's add the components. Component. Let's add a Rigid Body 2D. And let's also add a collider. And what kind of Collider should we add to it? Let's go ahead and add a circle. Sure, why not a circuit? Well, actually it should be a polygon collider. Let's make it a polygon collider and it fits perfectly. And actually just for the fun of it, let's go ahead and rotate it in the y-direction. No, not in the y direction. I meant in the z direction. Okay, great. So save that. But right now we are click, as you can see, we clicked on the diamond in our scene. We've actually added a rigid body and a polygon collider. So it's not added to our prefab. If we click back on our prefab and projects here below, we can see that it doesn't have any rigid body or collider. So back into diamonds. Click on override, Apply. And now in our second level, save that. And our level two, sorry for that. Scenes. Level to the diamond actually has rigid body and a polygon collider, which is great. So click on play just to see it fall. Diamond falls and everything falls. And as you can see, the, even, even the circle falls with r cube. But because it doesn't have a colloidal, nor does it have a rigid body, but it moves without cube. So I hope you did the challenge. I hope you enjoyed this video and I think this will be the last video on our section. In the next section, we're going to actually start creating our gain. So exciting. So review this, make sure you understand everything in this section and don't forget to always commit our work. So let's call this stay Joel. Add a diamond prefab and a child circuit to my magic. Cu O K TG rates or convinced that it saved, we have it in our commits right here. And I'll see you in the next video. 15. Section 3: Setting Up Our World - Game Design : Hello and welcome back, my favorite game developers. In this video, I'm going to talk a bit about game design. And as you can see, I've heard it started and already the Google slides are very excited to tell you about the gang sketch. So the game sketch is the following. Now, it's not very impressive, but it will get the concept of our game around. So you've already watched the introduction video where I showed you the game that we have finished already. But now I will take you through the steps that it took for me to get the game developed. So first thing first, I've created this mini sketch. And as you can see, well, it's not very impressive, but it gets the job done. So first thing first we have the tiles right here which will define our world. And we have the background tiles or the world combiners right here on both sides. Next thing we have are the doors. So we'll have the enter doors through which our conqueror right here, this little guy enter through and start the level. And this is the door right here that he has to go through in order to advance to the next level or room. Next thing we have the bombs right here that I've sketched as burning. And they will explode as soon as we get near them. Well, not as soon as they will start burning when we get near them and they will explode. Eventually, we have the hearts that we can pick up in order to increase the lives we have. We have, of course, the hanging sheets right here that we can climb to get two platforms that are unreachable. We have the diamonds, of course, that we pick up to increase our score. And we have the little monsters right here that will try to attack us and Canvas, but we have the power of source hammer that will crush any enemy and our path. And also we have this little square right here. And if you've noticed in the introduction, of course you've noticed because I've told you like ten times, because I'm so proud of it. This is the camera that will follow our player wherever he goes. So instead of having a huge camera around the entire leveled and having to move our tiny, tiny player around, we make the camera follow our player where ever he goes. That is very cool and I encourage you to create your own games sketch and see how you want to make your own game. So next thing, let's talk about the 2D platformers because our name is going to be a 2D platformers. So I'm sure you're familiar with a couple of these. This is a recent game called Celeste, which many regard as one of the best games of I think two thousand, two thousand seventeen. I'm not sure, but it's a fairly modern game. And as you can see, it's just like our game where it has toils and it has a pixelated character that moves around in the 2D platform that they have created. Next thing we have a hollow night. Not sure if you've played this game, but it's really amazing. It's similar to dark sauce and difficulty, but it's a 2D platformer. And I've used modern examples just to show you how much 2D platformers are still relevant in game development. And you can see right here that it also has a tile maps and platforms and backgrounds, and little pixelated. Although they are, but more polished than our game, and not as pixelated, but the same concept applies. And finally we have Shovel Knight. I'm not sure if you've played Chavan light, but it is an amazing game. I've played it, I finished it. It's very cool. And as you can see, this is very similar to our game. It has the ladders, it has the enemies, while the enemies are bigger, and it's pixelated just like our game. And the final example, I found this on Google. I'm not sure who did it, but as you can see, they have sketched up the game and the pixelated it and it shows the tiles that were used to create the game. We will use similar tiles or similar way of piling our game and making our game a 2D platform, just like this one would ladders platforms and with a background. So castle Conquest, game design, what am I going to talk about right here? So this is a screenshot of our game, and let's talk about the core mechanics. So we'll have our conqueror running, jumping, climbing, and he will also be attacking. What else should we talk about the core gameplay, but it's going to be getting from the start of the level, from the starting door to the end without getting hit more than three times. As you can see, as you saw in the introduction video, I've showed you that our player, or the conqueror is the player and our game has only three lives. And that's not talking about the large that he can actually pick up. Every time he gets it, he loses alive and if you lose three lives, you're done. You need to go back to the main menu. So let's talk about games story also because that is, you might think that, well, you know, I don't think we need a game story and you are completely wrong because the game story is, will the game story will be the, I'm not gonna say the core, but it is the nucleus around which the core is built. So what is our game story? Well, you are a king and you've just inherited the castle from your father. Monsters, pigs have taken it. And you need to defeat them all. And you need to go through every room and tried to crush every single one of them. And also along the way, you'll need to collect d1 times. So this will make the came much more interesting. And as you're playing through it, you can feel that you have the ability to take charge of whatever is happening in the game and you have a reason for killing the little pigs, not just for the sake of killing them. You'll have a reason and you're collecting diamonds for a reason because your castle is infested with them. You need to take back your pride. Okay, that's a bit dramatic, but you get the point. You always need a story for your game. Next thing we're going to talk about all the technical requirements to create this king. So as you can see, we had a lot of stuff. So first thing we need is a tile set for the background and the foreground with some elements. So I've chosen a tile sad that I will show you later on where I got it from. And I will leave it, of course, until resources. Feel free to go and get your own path sets. Make sure that you have a foreground and a background tile set for our game. Next thing, we're going to use inputs from the keyboard to control our gain. We will add a follow CAM that will follow the player or the conqueror wherever he goes and zoom in and out depending on his movement, as you saw in the introduction video, when we're running theorists, a certain zoom in, when we're standing still or idling, there is a certain zoom out and so on and so forth. And will also create an automatic way of adding background to our game. That means that will add a row, we'll add rules to our tiling and make all the background automatically fill everything and save us a lot of time. So let's talk about some more gameplay features that will have. As you can see right here, our little player is punching the air, but even though the pig is a bit far away, but the conquerors movement, we've covered this before, but it's going to be running, jumping and winning the hammer. As you can see right here depicted in our screenshot, there will be hazards. There will be bombs that will, that bombs that burn and explode if we're near and they can actually kill us. We will have a start and end point, will have doors that the conquered walks through to get from one room to the next. And by room, I mean the levels of our King. Next thing we'll have the pickups and the pickups, our lives along the way for the player to pick up as we walk and all the diamonds that you can carry with you. Now, it's time for your challenge, and your challenge is going to be to create your own game design. So figure out a story for our game. Think of a compelling story, a story that make whoever is sitting behind the computer and who's going to play your game, feel excited and give him reason. Giving him reason, give him the motivation to go and kill all the pigs and collect all the diamonds. Next thing you need to find out the game mechanics you want. Maybe you want to add other game mechanics. And I completely encourage you, even if you don't know how to actually implement those mechanics. Just to write them down, keep them with you. And along the way, you will find out how to create them. You will go and download your own sprites and typeset. And as I've told you, make sure that you have the foreground and the background. I will leave the links in the resources for you to go ahead and download all search for whatever tile sets and sprites you want. Or you can simply use the same, that amusing, figure out what features you want to add. So as I've told you, we have picking up things, we have climbing the sheets. You can also add your own features. I'm not sure what those will be, but for example, you can add power ups. That's a good idea. So write that down also and figure that out for yourself. And as I've told you, this is going to be very exciting and some pump to start creating this game. And I hope so are you. So let's start our journey to gather, and I'll see you in the next video. 16. How To Slice Up Sprites In Unity: Welcome back everyone. Now we are starting a new project which is very, very, very exciting. Oh, okay, so first thing, we are going to create our project. So open up your unity hub and go into add new. So it will be a 2D project. And we'll name this castle conquest to D. And remember, we're saving it because we'll need it for the repo to create. And now we wait for the project to be created. I'll see you in a bit. Welcome back. So I've accelerated the process of creating the Unity project using the magic of editing. And now we will, we are going to set up a new report. So this is from magic cube to setup a new ripple, simply click on the plus button up there. You can close this tab and click on the Create button right here. So we browse for our path. So wherever you've saved your path, go into that and click on the castle conquest 2D. Select the folder, keep it longer it keep the Create repository on account unchecked. For now. Click on Create. Click on yes. And now we have a repo. So as always, we know that we should simply click on the Library, ignore everything. Ignored everything beneath Library. Click on OK. Now we go into the gitignore. W click open and our notepad. And you should have everything by copying and pasting if you don't remember how we did it, check out the I'm not sure which video. I think it's the second video in the previous section. And you'll find where you can get the gitignore or simply Google it. And now we have everything set up. So we simply going to stage all commit and call this initial comment. Click on Commit, and we are ready to go. So first thing we're going to do is we're going to be importing the sprites I've provided you in the resources. So go ahead and get them. Simply click on them and drag them into our project right? Now before we get started, I want to take a moment and explain what is a sprite. So as this is a Sprite, This will be our hero or our conqueror. And as you can see, he is a image. So a sprite is a 2D object, and this 2D object has a graphical image on it called texture. So sprites are 2D objects and they have graphical images on them called textures. And they are used by adding a component called Sprite Renderer to an empty game object. So we create a game object, we add a sprite to it and we can have an graphical image on it. Okay, so now that we've explained what a sprite is, it's time for us to create our terrain. So our, before even that, it's time for us to slice up our terrain. So right now, if you click on the small arrow right here, and you can see that it's a single image. So what we need to do is we need to slice up. So if we click on it, you can see here in the inspector that we have many options and one of them as the sprite mode. First thing you need to make sure that your texture type is of sprite 2D and UI. And the sprite mode should be multiple. So click on that and apply everything and go into Sprite editor. So as you can see here, we have all of these. So the top ones will be our foreground and the bottom wounds will be our background. So here on the top, at the left you can see that we have multiple ways of slicing our sprites. One of them is automatic. So let's try that as an experiments or click on slides. We can see that it's slices them up pretty good, but that is not what we need. We don't want this entire block to be a single slice. We want to slice it up into four little sprites. This one also, I think more than that, I think this one is nine sprites. This one is for little sprites. So how can we do that? Well actually and slice, we have something that's called grid by cell size or grid by cell count, will be using the grid by cell size. And I know that it should, the pixel size should be 32 by 32. So we slice that up, click on slice, and now we have our sprite sheet sliced up into little sprites. Okay, great. And you can click on each one of them and check the information about it. So this is the rain, this is terrain also, and each of them has a number. Now if you have time and you want to be very meticulous with this process, you can actually glean, name each one of them and make it your own. But we don't need that honestly. Okay, great. So apply that on this pattern right here. Apply that. And now we have our sheets sliced up, Excellent and correct. And this is everything we'll need to do and it's time for a challenge. And your challenge is going to simply be sliced up your own spreadsheet. So import whatever sprite you choose to use for your game. I've given you the resources, the website where you can find free game arts and simply import them, slice them up into sprite sheets for the background and the foreground piles make sure that you have background and foreground. And as they less step of this process, we are simply going to create a folder. We'll call this sprites and will drag the terrain inside of it. And another thing maybe we'll change this and name this level 0 because we don't have any other levels, simply level 0. Ok, so this project will be great. It will have lots of sprites, two will have lots of scripts. So let's start with some good organization habit for the first video, and I'll see you in the next one. 17. Tile Maps In Unity: Welcome back everyone to another amazing video. And this especially is the best video, I think in the whole course, because we are actually creating our platform. As you can see here. We've made a small platform. We have the style map over here on the right, we have on the left also AOL mapping grid and our hierarchy. We used all the sprites that we've sliced before to create this platform right here. So let's not waste any time. I'm so excited for this video. I hope you are too. So I want you to summon all your creative power to this video and I'll see you in a bit. Okay, so tiled maps, what are we going to do? Well, first thing we did is we got our sprite sheets. We slice them up into little sprite sheets. We are going next to create tile assets. We're going to take those style assets and add them into our file palette. And finally, we'll use our Kyle pilots to create all tiled map. Oh, okay, great. So back to unity, where we are going to, first of all, go to Window and look for our tile palette, which should be under 2D and style pallet. So click on that. And now we have our palate. Feel free to dock it where ever you want. I feel like I want to talk next to the Inspector. Make this a little bit bigger because we are going to need it needed later on. Next step, we go into our hierarchy here on the left where we don't have anything except for main camera. So right-click and go to 2D object and look for tile map. When you click on it, we can see that a grid has been created. It's called the grid and our hierarchy and a tile map. So let's change the name of the style map to go into Inspector. Make sure you go from inspector to tile map. So tile map changes to back ground and create another one. So an ingredient we're going to create another tile map and we'll call the swan foreground. Oh, okay, great. And we'll also rename this from credit to tile, map, grew it. Everything is great. So now what we are going to do is we're going to create a new tile palette. So I'm going to tile palette and here under Create a new tile pilot. Click on it. And it will ask you for a name, will simply named this main main palate can create. And it will ask you where you want to save it. It's, these are your assets folder. So let's go ahead and create a new folder called tiles and save it inside of our tiles select folder. Now we have a new folder which is files and it has a main pipe palette. And this is our tile pallet. So. What are we going to do now? Go back into our sprites in the hierarchy on the left and choose all of these sprites. So go ahead and choose all of them. To do that more Fast. Click on the first one, go to the last one, hold shift and click on it so you choose everything and drag them into our tile palette. And we should have a big, huge master. Ok. Now, go back tiles and inside of tiles, select the folder and save them there. So wait for them to become pile assets. And they should be at now o k. So as you can see, a huge mass has been made. Now of course, we are going to be moving all of these and rearranging them. Now you can rearrange them the way you want to. I will do later on. I will, it will be the same arrangement as the one on the terrain. Feel free to do your own arrangement. So now it's time for the exciting part. So let's choose one of these tiles and start drawing. But as you can see, these are very small. So what's the problem? Problem is that when we are choosing our sprites, they are actually the pixels per unit is 100. So how are we going to make them fit? We're going to change this to 32. So go to our sprite, click on it, go to the inspector and make sure that the pixel per unit is 32. Apply that and they fit perfectly into R-squares. Great, back to our tile palette. And now let's go ahead and draw a simple, very, very simple background. So we can also learn a bit about the stuff up here. So every time you want to draw, you have to make sure on which active tile map you are. So for example, I just drew a abit of tires which were on the ground, which was not correct. You need to make sure you choose the right active tile map. And over that you can see that we have this brush with which allows us to draw a single file every time we have next to it, this box drawing, which we can simply click on here and drag it and make as many boxes as we'd like. We have this, pick where we choose one of these and we can actually change all of them. And now you can also experiment with all of this. And we finally have this. This is a, an eraser which where we can remove whatever we feel like removing. So let's draw this again. And now we are going to change into foreground. And now when we are foreground, we choose the tiles for the foreground. Back to background. Make sure that we, everything is in the background and the things in foreground are always the tiles for Foreground. So now if we click on play. This will be our game view. How cool is that we're beginning to create our game. Excellent. But something I want to point out is that we need to make sure that we are working on the right layers. So what do I mean by that? Well, if we go back into seen and our tile palettes, if you click on the background, we can actually draw over our foreground, but tiles, which is not very good, we need to make sure that when ever we draw, our foreground is well in the foreground. So how do we do that? We do that using sorting layers. Sorting layers are very, very who'll aspect. So if you go into the hierarchy in the background, you can see that we have a tile map. Under that, we have a tile map rendered. Now, if you want to go into the unit documentation and find out everything about everything, feel free to do that. But what we're going to focus on are these additional settings. So if you have it closed, open end up. And you can see that we have sorting layers and we have ordered layers. And now on foreground, you can see that we have these sorting layer and ordered layer. So we need to create a sorting layer for our backgrounds. So click on the sorting layer which is now default and click on Add sorting layer. So to add a sorting layer, simply click on this plus right here, and we'll call this R for ground. Let's add another sorting layer and make this one back ground. Now we have two sorting layers and below it, and above it we can see the tags, which something that's useful for coding, and layers below it, which is good for collisions, will talk about these later on. So go back and to foreground. And now in the sorting layer, instead of default choose foreground and for the background, choose background. But as you can see here, our background still is in front of our foreground. Why is that? Well, if we go back into the layers to sorting layers, the ones below will be rendered first. So if we move up the background and put it above the foreground, the foreground will be rendered in front of the background. And every time you need to make sure that you have your layers in the right ascension or dissension. Okay, excellent, save that. And now we are going to create a simple platform. A very simple platform. But first, note, not challenged, not yet. First, I will use the magic of editing to rearrange all of these styles in here. And it's not going to be something very amazing you can do with the way you wish to do it. I'll simply make it the same as our original arrangement. Okay, I'm back from my magical editing trip. So as you can see, I've rearranged all of my tiles and I forgot to do something. I forgot to teach you how to actually do that. So. Excuse me to do that, simply click here on edit. When you click it, you actually have access to all of these tiles. So if you check on here, you can actually select an area of the grid using S and then you can move it using AMP. So click on us, click on one of the Tiles, click on M, and now you can move it wherever you want. And when you finish editing, simply click on this edit button and it will save four. So let's change this back as an OMB and save and control S to save everything. And now it's time for your challenge. And your challenge is going to be to be to create your own platform. So create the foreground and background tiles. Create a new tile palette and rearrange the toils in that ballot just as I did. Or find your own personal way or rearranging them, create a platform from the foreground with a background. So pause the video right now. Rearrange the tiles the way you want them to be rearranged and then go ahead and create some kind of platform. Don't worry about how much the platform should be. Amazing or great. This is just for simple training. I'll do it later on. But pause the video right now and try your best. O k. How did you get on with that? I am so excited to see what your pallet would look like. So now I am going to create a small tile just inside of our screen. Free dog the game right next to it, and it's 16.9 grade. So we can see it. But for now let's simply keep it there. And I'm going to create a platform just inside this camera and to not bore you with all the details and going to, again, use the magical editing. It's such a good magic. It's better than Harry Potter's magic. And I'm going to create a grid or writing. So I'll see you in. Hello and welcome back. So as you can see, I've created a small platform right here. And what this platform consists of, just I made a small for small I rather big wall in here, an obstacle. Maybe I'll make it smaller Later on I made a little platform here where we may, we might put, I don't know, maybe diamonds or hidden box. Then I made these kinds of steps where our player can jump on. And that's basically it. Nothing too fancy. And I hope you did to create your own platform or you might have waited for me to create the platform and then took inspiration from it. But what I want you to do is create your own platform. Don't just copy mine because this is the best part in the course. It's actually creating levels using the amazing magic of tile maps, a lot of magic in this video and see you in the next one. 18. Rule Tiles 101 (2D Extras): Welcome back everyone to a brand new video. And this video, we are going to be investing time. Yes, we'll be investing time right now to save ourselves a lot of time later. And we'll do that by creating the rules for our tiles. So as you can see, and now we can simply automatically create tiles. So as you can see, they fill up automatically, which is very cool and very helpful. So i'll be teaching you how to create these rules. I'll give you all the resources needed. It will take some time and some understand, some understanding to get it, but don't worry about it. Everything will be explained. So I'll see you in a k. So first thing we're going to do is we're going to be importing our 2D extras tile map role. There are two ways to go about this. You can either go into a google and type to the extras unity, and then go into your, into the first result, which is GitHub and downloaded it, downloaded from here, you will get a zip folder and you simply have to import it. First of all extracted and then you simply drag it into your Unity assets or you can use the one I've provided you the resources. I will use that right now. So simply take this role tile that I've provided, drag it into Unity and put it inside of assets. Wait for it on port. It will give you a long list of things to import. Simply click on import right here on the bottom right corner. Wait for it to finish up. And now you should have this folder right here. When you do get this folder, you can go into tiles. And you can simply, let's go ahead and put all of these in a single folder. Let's go ahead and call this terrain rain files. Go ahead, choose all of these and simply drag them into terrain tiles to have more space. And now, if you right-click on your whatever you want, I recommend you go into tiles, go into create. And you can find at the top right here that you have something new. 11 is a prefab branch and the other is ruled out. So click on router and went for this particular rule set, we are going to make rules for our background. So let's go ahead and call this background rule filing. And now if we click on it and go into the inspector, you can see here that we have some weird structure of Windows. So we have the default sprite and we have the tile rules, a list which is empty. And we can add to this list by clicking this button right here, and we can add rules. First thing you need to do is dock this inspector. So simply go up to the upper right of your screen and click on this little lock here. And now this will not change. This will be very helpful. So now, as you can see, it tells us that there are none. Sprite. So we need to add a default sprite. And because we are working on the background will be only working on the background sprites. So go ahead and add what ever random sprite you want to be the default. And now we're going to start by creating our tiling rules. So the first rule will be for a tile which should be in the middle, just like this one. Which doesn't, doesn't have any sides to it or neither does it have any little natural what those are. Those are called, these are for the corners by the way, and this will become all clear, just enabled. Now we've created our first rule. Congratulations. Let's go ahead and add it to our tile palate. So you can either create a new tile palette simply just for our rules or you can add right here of the, above all the default piles all added into this one. Because it's more practical, I believe. So simply click on this background and drag it into our tile palette and should, it should show right here. So now if we click on this one, we can actually draw these rule tiles. See that? Oh, okay, great. And as you can see, the, all of them are of the same type. But if we choose to create rules for it. So for example, if we click on this one, as you can see, everything changes. Why is that? Well, let me explain these how these rules actually work. So let's see this three-by-three box right here. And if we add, we can actually add these kind of arrows. And as you can see, the more we add the moral changes. And what these mean is the green arrow means that there is a tile above it. So when the restyle above it, to the left, to the right of it and below it, then we can draw this style. So this is a rule. And if we click on this green arrow, again, we can see that it becomes an a red X. And what this red X means that it will only draw when there is nothing to its right. And we can see here o. And if we actually click here, it actually makes, well, it shows us what will happen if we add a title here. And you might be wondering why are all the other tiles this way? Well, because it's our default sprite. So let's go ahead and add a nother rule. And let's keep this like this because actually this is our rule for this particular tile. So let's go ahead and add in another room. And for this rule, let's go back into sprites. Will add a corner on the right side. So let's go ahead. So what do you think the right slide should have as its rules? Well, I think it should have one below it, 12ths, right? And one on its diagonal, and it shouldn't have anything on either side. Now nothing changed pretty much, but that's okay because we'll add another rule. And for this rule, let's see what we have. Let's add this 10. And in this case, if we have something to, on these sides and nothing on that side, we should have this right here. And it's pretty much correct now. So let's go ahead and create a nother rule and add this one to it. So now, if we have, for example, what should this have? If it doesn't have anything to its right and it has something on its left, it should create this One. Another thing about these rules right here is that you can actually change them and they can be either rotated mirror on the x or y axis. What does that mean? Well, if we click on this one, you can see that it rotates all the rules. So if we don't want to create rules for, for example, we want to make a rule that's like this one. Okay? We can simply click on the Mirror, mirror on the x axis, and it will create that rule for us. But we won't be needing that because our assets are rich and they have everything in them. So now I'm going to create a set of rules that's simply believed that one because we needed, I'm going to create a set of rules. And before I do that, I'm going to issue you a challenge and your challenge is going to set up your own rules. Because may I believe even that you can create battled rules than me for the background. So first thing is imported to the extras file I've provided in the resources. Then you have to set up your rules for automatic tiling and use the rules to paint your own platform. So go ahead and try your best. And if you feel that you can't even come up with the simplest rules I have provided in the resources. Also, the rules I've screenshotted everything beforehand, so I'll see you in a bit. Okay. Welcome back. So how did you get on with that? I hope you at least tried to create some rules. So let's show you, let me show you what I've done. So I've created, I think it's about 17 rules. And the way I did them, I actually started looking at different ways that each tile might work and how it should be positioned. Of course, if you don't have any idea how to create the rules, I've provided Jews some pictures and, or screenshots that I've made so you can copy them and use my tiles. But remember, mine are not perfect by any means. And I left out a lot of tiles because it's a very exhaustive list. I want to create an example for you to create your own rules. It will not be easy, it will not be done in ten minutes. I think this actually took me me I think about two maybe 2.5 hours to finish all of them and test them and make sure all of them work. So to demonstrate how the automatic tiling works, let's go ahead and choose to erase a couple of them. So as you can see, when we erase them, new tiles are created to wrap around. And as you can see, we have a mistake right here. And then there might be a lot of other mistakes, but some of them worked like this one, for example, works perfectly fine. So let's go ahead and delete all of these and lead all of these. And let's try them out in our platform and see how they work. So let's go ahead and click on this, choose the automatic tiles. And let's remember to always have it on background. So let's create something right here, and then we'll create something right here. And as you can see, they fill up automatically. And it's perfect, I guess let's see if, oh, there's something right here. I think we need to create another rule for that. I believe it's the one where you have only two on each side. So let's see. Okay, so let's go ahead and create a new rule and let's see which one we should use. So we want to cover, we want to cover this area right here at the top and one over here. So we'll choose which one, which one, okay, this one. So let's drag it in here. As you can see, it fills up automatically, but that's not what we want. We want to actually create a rule for it to always follow, because that will always default to us. So it doesn't have a tile to its upper left. It doesn't have a tied to its bottom right. And it has tiles to both sides and vows to above it and below it and on either side. Excellent. So now you can see that we have our rule setup right here. We can automatically tile all the background. It makes our platform much more static than having all of them the same. You can create gate, also a rule for your foreground tiles. I tried it. It's meticulous, takes time, and I encourage you to try and create that also, it will make your life 20 times easier. I hope you enjoyed the video. I hope you're excited as I am about this in the next video, I think will be finally adding our player or a conqueror us, call us, we'll be calling him our conqueror. So I'll see you in the next video. 19. Adding Our First Animations: Welcome back, my fellow game developers. As you can see, we've created, finally, we've created a player and display or is our conqueror, we'll call him Ginny. So Jimmy right now doesn't do anything. But if we click on play, we can see that our jimmy conqueror actually has an idling animation that's running right here below. I'll teach you everything that we've done. You will have a big challenge. So I want you to give me your entire concentration force and I'll see you in a bit. Okay, so first thing we are going to do is we're going to undock this and we're going to delete all the unnecessary things we have up here. So let's go ahead and delete all of that. Zoom back in and go to Arlen Specter, saved that. Then let's go and create an empty game object and make the smaller within dont needed that big. Click on that to remove a little bit bigger and we'll call this game object our layer. And this layer will be reset to the middle of our screen. And honestly, this is the most exciting part of all game creation when you start making your player. So let's go over some technical words. Animation 101 first, first thing you need to learn as an animator controller. So an animator controller allows you to arrange and maintain a set of animation clips. You'll see what that is enabled. And Animator component used to assign animation to end game objects in your scene. So if you have a game object and you wanted to have animations, you assign it an Animator component, and that animator, animator component gets an animator controller. It's a bit confusing. We'll see everything. Animations at several sprites rendered one after the other. So it say set of sprites one after the other, we put them next. Just like video works where it's a set of images one after the other. And finally a sprite renderer we've talked about previously, renders a sprite for 2D graphics. Okay, grew Rick. So back to Unity. And from unity we are going to be importing the sprite. I've left you and their resources for our human. So let's go ahead and go there. And here you can find that we have fall idle, jump and run. So we'll use for now idle animation. But in order to create the other animations we have the Ron and all jump. So click on the idle and drag it into our unity. So we have it right here. I'll actually, we don't want, we wanted inside of sprites. So let's close that and now let's create a folder. First for our. Conqueror, who call this conqueror. And our conqueror will have this sprite. First thing we're going to do is we're going to be slicing up our conqueror. But before we do that, I want to, to understand the steps that we are coming to take. So we're going to import the concordance spreadsheet and slice them up. We're going to create the player object. We've already done that and add a sprite renderer to it. We'll do that right now. We're create will create an idle animation. We'll add an animator to our player, will create a player animator and ordered to add all the animations to it, will add an idle animation to the Animator, and we'll assign the animator to our player. So let's go ahead and do all of those things. First thing, let's slice up our. So we'll go to multiple will make the pixels per units 32, and we'll apply all of that will go into our sprite editor. So as you can see here, we have 1234567891011 Sprites, and they are spread over 800. Here below you can see it eight hundred and fifty, eight hundred fifty eight. If you do automatic slicing, you can see that it does the job pretty well. But the problem is that when we'll be adding other animations to our conqueror will have a slight problem with that. That's why I'm going to slice it up in a manual way. And it's going to be 58 by 58. We sliced that up. And as you can see, it's not very accurate. Why is that? Because we want to have some kind of offset. Why we need that offset? Well, because 50 by 58 just doesn't cut it. And we're going to pad let's do a padding of I mean an offset of 20. Nope, I meant padding, so padding of 20. And now we can see that they are all in the middle of, the most important thing is to have our conqueror and site in the middle of the sprite. So all of them are in the middle. And Oh, okay, great. So slice that up, apply everything you can. As always, I've told you you can rename them if you want to go down the throat. So we've sliced up our sprites. Now it's time to add our renderer. The way we do that is we'll move this here and we'll add a component. And it's going to be a sprite renderer. And, and our sprite render, we have this default sprite. Choose anyone you'd like and put it inside of it. And we have our layer, a girl rate. So now what we need to do is we'll need to add an animator to that player, or actually an Animator component that we've talked about. So let's do that. Simply type in and he may talk. Now we have an animator controller and this object can now begin to have animations back into assets. Let's create a folder. We'll call this folder. And animations. And inside of animations, we are going to create an animator, so animator controller. And we'll call this the player. Now, let's get back who act should we do right now? Okay, so next step is going to be, we're going to open up our window for an animation. So go into animation and click on the Animator window, animations animator. And we have the animator, but we are going to docket in a different way. Feel free to dock it however you want. This is my personal style, so I'll dock the project and console next to each other. And I will dock the animator weight of what, and I'll dock the animator right here below K. You need to do a couple of restructuring right here. Just like that, and it's perfect. So this is our animator right here below our scene. And we'll add also a window for the animations. So animations and will dock it next to the animator. Just like that. Okay, great. Next thing we're going to do is we're going to create an animation and we'll be adding it to our animator. So as you can see, we already have a couple of states. These are called states. This is the entry state, This is from any state, and this one right here is an exit state. So let's create an animation best part of our game. So go back to sprites conqueror. And the way we create animations is we choose all the sprites that we want. So as I've told you before, click on the first one, go to the last one, hold Shift, Click on them, you've chosen all of them, right-click on it and go to Create, and go down into animation. So this will create an animation. We'll call this idling. Idling. Okay, great. Now we have an animation of idling for our player. Simply drag that into animation. And inside of animation, we have to now add this idling animation, 2D animator. So we do that by simply click on, Click on the widening and drag it into the animator. And now we have an idling animation for our player. One thing we also have to make sure of is we click on animation and add a loop time because of we don't. He'll do this animation once and then stop. I blink is an animation that we want to have over and over and over and over. So click on that. Save all of this, and don't forget to go to player. And in the animator controller, it will ask you for a controller. You can either drag this here or you can click on the little circle and add the player animator. Save that. And now let's click on play and see what we've done or anything works at all. So if we go back to seeing, we can see that our player moves and he is idling woo, woo, Oh, okay, great. Very exciting. It is very exciting, but there is a problem. If we take our player right now and drag them into our platform, we cannot see anything. So where is he? What's the problem? The problem as well? It's actually your problem because see what I did there. I actually changed the everything the steps into I challenge because maybe you're just watching and not doing anything too. So this is your chance to do the challenge. So your challenge is to do all of the things that we've done already. You can re-watch it. Maybe you already doing everything with me and pausing the video. But if you're not, now's the time. And your extra challenge is to use the sorting layers to make our player visible in front of the background. So we've covered sorting layers before. I think you have enough skill to do all of them. And I'll see you in a bit. Welcome back. I hope you did your best and that challenge, I hope you just stare at the screen. So we'll choose player will go into sprite renderer. And we see here that we have the sorting layer just as we had for the foreground and background. So if we click on Default, we don't have a player and we can add a sorting layer. So let's go ahead and do that. So a new layer, we'll call this deep layer, Layer. Layer, Layer. That's fun to say. And we'll put it in front of background and behind foreground, Even though he will not be going over the foreground or behind it. But we'll render it that way. Save all of that back to Player, and choose the sorting layer to be the player. So now our player, our player is on the player layer, say that ten times. And now I, actually, I think that our player is just a little bit sits mall, I think will make him bigger. So let's go into sprites. And the way we do that, we choose the conquerors, playwrights, and we'll make this 30. So if we make this 13, Click on Apply, he becomes just a little bit bigger, just so he can be seen. But and if this camera logo and here is bothering you, it's bothering me. You can actually click up here on the gizmos and you can make all the icons is smaller. You can even make them disappear. Okay, great. So I hope you get on with that challenge. I hope you are excited as I am because our player is actually moving and we have breathe some life into our game. I'll see you in the next one. This is Michelle from the future. Sorry to interrupt. But I want you to do something that we haven't been doing so far. And that is committing our changes. Maybe you've been doing that and I congratulate you. But if you're not, this is a great time to start touring. So as you can see, I've been doing it each video. So slicing up sheets, creating pallets, created a platform and the tools. And now we're going to add the animation. So we'll commit that change and adding an animation or adding idling animations. So if you haven't been doing the repos right here, this is a great time to start because we are going to be doing a lot of things in the upcoming videos. So I'll see you. 20. Animation Transitions: Welcome back my fellow game developers to a brand new video. And this one is very exciting because we're going to be learning about nother, other animations and even more transitions. So as you can see here in our animator, we've added two new states which are climbing and running. And we've added transitions between them with also added parameters that will allow us to make those transitions. And now, if we click on play, we can actually take our player from the ironing animation into the running animation. And we also a climbing animation from what we have. So I'm very excited for this video. I hope so. I hope you are too. So let's get into it. First thing we'll do is we'll go and add the sprites for running and the client. So for the running, we have this runs sprites and 40 climbing. I am going to use the fall and the jump because we don't have the actual climbing animations, but I wanted to include that in our project. So go ahead, click on all of those and drag them into our unity. So we have jump, we have the, either the Iran and default. For now let's just focus on the running. So as you know, this is a step that we've done multiple times. Let's go ahead and click on run. Make it multiple, make the pixel size 30. Because as you remember, we've increased sizable. Save that. And yes, I meant to apply, go back to R1 and for some reason, okay, so going to Sprite Editor, and we have those sprites, it's go to grid by cell size. It should be 58 by 58 with a padding of 20, as I remember, yes, exactly. Okay, so apply that. Now we have our sprites. Let's go ahead and click on all of them as we did before. Check all of them. Right-click. Go to create animation. And we'll call this running chronic, great clothes that take running into animations. And later on, we'll create a folder. So now let's add the running animation state to our, an animator at running right there. So now this is a bit tricky, but let's zoom in, move that exit, exit to overhear. And now we have the idling and the running next to each other. So how are we going to tell our animator that we want to transition from the idling into the running. Well, if you right-click on idling, you can actually make a transition. So make that transition and push the arrow and to the right. And if you click on that transition, as you can see, we have lots of options and lots of settings also. So let me tell you just a bit here. Let's talk about transitions. We have a bit of blending here between the animations, but we don't want that to, as you can see, we have this blending right about here and we can actually. Remove all that blending. So it goes immediately from idling to run. And we'll do that because we already have very good to the animations. So we can simply go into Transition Duration and put it to 0. That way there will be no lag between animations. So now we have the idling going to running. But how is it going to know that we actually want to go down that road? Well, we do that using the parameters here on the left. So go from layers into parameters. As you can see, we have an empty list. So here is where we start adding parameters and we can add and a couple of parameters. We can add a float and an integer, a Boolean or a trigger. For now we'll be using a boolean and that boolean will be called running. So we want to transition into running. We'll need to use the running Boolean. And in order to add it under the, if we click back on transitions, we have the conditions right here. And this condition, this is empty. So click on plus an atom. It automatically adds the running because we don't have anything else to add. And now if we click on play, we can see that we are right now idling. And if we click on this Boolean, we go into the running, but it does, does it only once? Why is that? I will give you a mini challenge right now to figure it out. Okay, enough. So let's see, running should be in a loop. Save that back into play. And now if we click on the boolean, he starts running and he keeps running forever. Why is that? We want to make this butter. So we'll add a transition back from running to eye-opening. And this transition will also have a duration of 0. It's conditioned right here will be running, but when it's turned to false, save that again. Click on play. And now our player as ironing. And now he's running and now he's not running and now he's running. And now he's not running. Okay, so this is very cool. This is a very exciting and this is a great time for your challenge Soviet challenges to create the climbing animation TO important declining sprites from resources. Slice them up, and size them appropriately. Create a transition from idling and to running. And finally create a trigger 40 transition. So pause the video right now, i given, I've given you all the steps that you need. I want you to try your best. So I'll see you in a bit. Welcome back. So how did you get on with that? Let's go ahead and do the challenge. So first thing we'll do is we'll go into our Congress sprite. And as I've told you, will be using the fall and the jump animation in order to create our animation. So this will be a bit tricky. And now we'll go to our fall. So our false should be. Thirty-two, and we'll make it multiple even though we don't need to do that. But because we are going to slice syrup our way. So what's 58 by 58 apply? We only have one sprite, and in here also we have only one sprite. So apply that. Don't forget to make it 30, not 3416 sliced up, apply. Correct. So now we are ready to use these two. So let's click on those, right-click and create an animation, and we'll call this lining. So climbing animation back into our animation folder, and we'll add it into our animator, will create a transition from either link to climbing. And they transitioned from climbing to idling will also turn off of the transition duration on both of them. And we'll create a new parameter, which will be a Boolean. And we'll call this climbing. Climbing. And now we'll add this condition to from idling to climbing. The climbing should be true, and from climbing to idling, the climbing should be false. Save that. Click on play to we put it into loop. I'm not sure. Let's try it. So climbing and it stops because we haven't put it into looping, save that again. And now, if we click on climbing, he starts climbing, but as you can see, it's kind of super-fast. So let's go ahead and play around with our animation. How do we do that? So we have an animation tabloid here that we haven't used them yet. So from animator to animation, and as you can see here, we have this climbing. If we click on player up in the hierarchy, we have the widening, We have the running, and we have the climbing. If you click on any one of those, for example, idling, you can see that it tells us which things change during the animation. For example, here the thing that is changing is the sprite. So we can actually take it frame by frame or play it right here. And we can see that our player moves with the idling. And you can see every single frame. And you can go forward and backwards, make it smaller, make it bigger. So we'll use that for the climbing. Why is the cost? As you saw, the climbing is extremely fast and we want to slow it down just a little bit. So how are we going to do that? Well, goes from here to here, so we'll add another one. So copy that. Click on Control C. Go to the frame where you want to put this sprite and Control V. Ok, so now we have these two. Well actually let's choose both of these. Control-c, Control-V. And then again source three times. Let's make it 1 second. Okay, let's see how that works. Click on play. It's a bit first still. But at least he does it multiple times. And we can actually, let's take them apart if we choose all of these, and that's what let's delete the last two and choose all of these. And we actually can spread them out over a second. And now if we click on play, will be a little bit, something goes wrong, right? Why is that? Because the last frame, well, actually they're not spread out correctly, so let's spread them out correctly. So this is on for 68 on the one. And the last frame should be the same as the first frame. So let's put in that one. And now if we click on Play, it should be very, very small. So a final step before we go, I want to go into player. I want to go into the animator actually, and I want to remove the exit time. As you can see, we have something in here that's called exit time. And this is used when you want to transition back into the previous animation or go into the next animation after a certain time. And we don't want this right now, will be using it in the future. Go into every single transition and remove the exit time. And we are done. So let's save that. Let's click on play and see what we have. So we have our player idling. And if we click on running, he starts running and we amplicon of running, he stops and he also climbs. How cool is that? Seriously, this is the coolest part. And I hope you enjoyed the video. I hope you learned a lot. And don't forget to save and the repo. And I'll see you in the next video. 21. Adding 2D Collisions: Welcome back, everyone. Just wanted to remind you of the amazing job you've been doing so far. In this video, we'll be adding a rigid body and a collider to our player, will also be adding collisions to our environment, as you can see here, that will make or unable our player to land on the surface of our foreground. So now if we click on play, our player actually stands on the surface. So let's get started. Okay, so let's start off by adding a rigid body to our player. But before we do that, I think it's a great time for us too. Prefab out player. So do that, let's go into our assets. Right-click and create a folder, and we'll name this folder prefabs. Let's go ahead and prefab our layer. So now we have a player prefab, which feels good. So back to our player. Let's go ahead and add a Rigid Body to our layer. So Rigid Body 2D. And we'll make sure that we have it as dynamic, save that, and apply it to our preferred. The way we do that as we go to overwrite, click on down and there will be an apply o. Okay, great. Before we continue, I wanted to take a second and talk about rigid bodies to the one more time. So it's a component added to a game object that subjects it. Two should not be TPI, it should be to physics, engine forces. And we have many body types of Rigid Body 2D. So we have dynamic, which has finite mass and is affected by gravity and other forces. We have kinematic that isn't affected by gravity and other forces. And we have static which behaves like an immovable object. Oh, okay, great. Now back into Unity. And because we have a rigid body, now, if we click on play, our player falls through the ground. O k. Not very helpful, but it's a step forward. So now it's time for your challenge. It's important of an early challenge, but I think you have covered. So we've talked about collisions before. So now it's time to add the appropriate collider to your player. You need to add a collision to the environment. And you have to make sure that your player lands on platform without falling through. So pause the video right now if you feel that you have skills to do that, F naught, wait a couple of seconds and I'll be right with you. Oh, okay, so colliders, they are very helpful. So go into player. Let's close down this rigid body. And let's go ahead and add a collider. So I think we'll be adding a Box Collider 2D to our player. And as you can see, our play or our box collider is a bit too big for our player. So we'll go ahead and shrink it down. And You can do this however you want. It depends on your preference to the gain, how much you want to make the Foxconn life big or small. But what you need to keep in mind is that his feet should be touching the bottom of the collider. So let's make it this big. And this is simply based on your preferences. I like to keep it just smaller than his actual size to make the game a little bit fair. So if you make the box collider bigger, that will make the game a little bit more difficult. And if you make it smaller, it will make it easier for your players. So I think this is good enough. So save that and as always, go to override and apply it to the prefab. So now if we click on play, our player still falls through. Why is that? Well, because we don't have any colliders on our foreground. So let's go and add some go into foreground. And if you got to this point and couldn't continue, don't worry about it because this is something you will be adding a tile map called lighter. So let's go into pile map. And as you can see, all of the foreground tiles have been, have now a collider on them. But the problem is that if you zoom in, you can see or you can't. But if you zoom I a lot, you can see that there is a tiny, tiny, tiny gap between the colliders. And believe it or not, this will cause problems for us later on, especially if the player is moving or dropping down active very fast velocity, he can go through these colliders. So how are we going to fix that? Well, there is a small solution that is called a composite collider to the, so let's see what that does. So Composite collider to the, when we add that, it automatically adds a rigid body to our foreground. And what this does, it actually lets close this. And if we click here, if we look into our tile map collider, we can see that we have a checkbox that is called used by composite. And what this does if we click on it, you can see that all of the colliders are now on a single collider, but we can see it. Let's make this bigger. Okay, so now you can see that we have a single line of collision to our foreground. So now if we save that, oh, and there is one more problem. Well, you should have thought of it. Maybe you didn't. That's okay. I've invested a lot of times because we have a rigid body on her foreground. If we keep it on dynamic, all over the world will be falling down. So we need to change this dynamic into static. That way it stays in its place, whatever happens, so save that they can play. And now our player spends on our foreground. Now the game is becoming more and more realistic. So this is great. This is a very big leap forward. But there is one other problem, because if we click on our player and we sat him here on the edge and click on play. We can see that he actually falls on his head. And now the animation is plates. Well, it is kind of cool, you know, but we don't want that. So in order to avoid this type of behavior from our player, we can actually go into our not rigid body, excuse me. We can go into our, into our rigid body. And down here we can see that we have something called constraints. So this constraints the movement of our player on certain rotations, for certain rotations. So what we want is to freeze the rotation on the z axis. If you look here at the top of the transport, if we use the z rotation, R player rotates. So this is the one that will be freezing. Okay, great. Is it's still pleased. We needed to override apply all. And now let's close that. Why is it telling me that I need to change my collider or cake layer can play, and now our player stands using his hammer. It's not very realistic, but it's a 2D platformer and it's OK. We don't need it to be very realistic. So I hope you enjoyed the video. I hope you try to do the challenge and I'll see you in the next one. 22. Section 4: Moving Our Conqueror Horizontally: Welcome back to another video and start of a new chapter in our game development journey. In this video, we are going to start moving. Our player based on keyboard input will be using the same formula as we did for the previous project or for the magic Game Cube, but with a different twist to it that we'll see in a bit. So as you can see, we press the right arrow, he moves right. We pass on the left arrow, he moves left. And I'll see you in a. Okay, so as the title suggests, we want to manipulate our game object's behavior. So what does that need? Well, that needs a is correct and that means coding, which is very exciting and a bit scary. So let's go ahead and add a script to our layer, whereas our player, we already have him. So let's go to Add Component and create a script that we will call simply player. Down here we have news corrupt and will create and add a script. Wait for it to understand what is happening. And okay, so let's start by creating a folder. One of my personal favorite things to do, apparently so scripts, scripts, and we'll add the layer into our scripts. Great, let's double-click on that. And let's wait for Visual Studio to open up and understand everything. Okay, so I wanted to initially do that, initially drew the challenge later on, but I think I'll do it just now. So if you are ready, you can take the initiative and move your layer. First thing you do is import a cross plot for platform input as it package that I've provided you and the resources. Then you create a run method that is called from inside of update. And then inside of Ron use the rigid body to move the player. And finally, add a variable to control our speed. So it's a bit of a daunting task. If you think you have enough skills, do it, go ahead and pause the video and try it. If not, and you think it's too big of a mountain to climb, Wait for me, I will do it in front of you. And one more thing if at any point you feel that you can continue it alone, I recommend that you pause the video and you do it. So I'll see you in, just tape it. Okay, welcome back. So maybe you've tried to add the cross-platform input from the resources I've provided you. But you can also go into Unity's Asset Store and search for standard assets, which has the cross-platform input inside. What is cross platform input? Well, it's something that we'll be using instead of input. And it literally does what it says. What named this? Well, it's cross-platform input. That means it's across multiple platforms. So this game that we are creating right now could be on a Computer on a PC, or maybe it can be on a PlayStation five that's coming out recently. But of course, like this isn't going to be a PlayStation five games, but who knows? Maybe you could create a PlayStation five from this simple graphics. Anyways, let's go ahead and import the cross-platform package. So simply go into the resources and drag the cross-platform package into our assets to, I'll ask you to, do you want to import all of these? Simply click, oh, what is this? Okay, don't worry about that. We've already imported that and what we do need as the standard assets. So go ahead, look for cross-platform. Click on that and now simply click on import. Only need the cross-platform assets. And if you've downloaded the standard assets from the internet, also only choose the cross platform. There's no bad thing to do well if you import everything, but for now we just need the cross-platform. So wait for that to import. And now we should have a folder that's called cross-platform folder. And let's go ahead and add the 2D extras, which is under the File 7.15 whatever, into our standard asset to make everything but more cohesive. As I'd like to say, save that. Let's go back into Visual Studio. And because there is a file modification detected, it will ask you for a reload. Simply reload. Reload again. It shouldn't do it anymore. Everything is fine. Okay, so first thing we are going to do, we'll be adding a using cross-platform. That means at the top here. And I'm not sure I've explained this enough. These are the libraries that we are using. For example, the Unity engine is the library for the start and the update and all other Unity related things that we use an R script. So now we have to import the cross-platform library and we do that by typing using Unity standard assets dot cross platform inputs. So now we have access to the cross platform input. Next thing we're going to do is we're going to create a run method. This would be a private method. It will not return anything. That means it's a void and it will be called run. And what should we do inside of run? Well, we're going to use the get-x method and get the horizontal. So, well, first thing we're going to do is we're going to put it inside of a variable. So it's going to be a float. It's going to be, let's call this. Control throw. And it's going to be u using instead of input will use cross platform input manager, I'd say big word, but it's what we use instead of input. It's going to use dot get axis. Now, inside of get axis will need string name for our inputs. And where will we get that? Well, let's go back and to unity here. And if we go to edit and we look for project settings, we can see that we have our Input Manager that opens up. And if you don't have it opened up, simply click on Input Manager. So this is where we have our project settings. There are a lot of things in here. We don't need to go over all of them. So for example, we have physics 2D, which we'll be using very soon. But for now, let's focus on input manager. We have this axis here. And if we click on that, we can see that we have a lot of options. So, and one of them is the horizontal. Horizontal as when we click on the a or the, and this is exactly what we need. So because and here they get access needs a string reference. Well, go back and to the input manager. And every time we have a string reference, we always go and copy it. We never assumed that we've written it correctly because we never do and we cannot find the error. So we have a control throw. And why did we use a float variable to catch this important? Because I will demonstrate it. So if we click here print and we'll control throw, let's print that out and see what happens. And that's not forgot to call it in the update method. So save that back into Unity. That's dark this here next to our tile palette. And that's, I think is a good place. And now if we click on the play and we click on the left, on the left arrow, you can see that it slows the goes from 0 to minus one and then back to almost 0. And if we click on the right arrow, it goes from 0 slowly to one. And that's why we need to save it inside of a variable to always have control over. So now that we have at, let's delete this print right here. It was only to demonstrate how this works. Next thing we're going to do is we're going to create a player velocity of vector type two. So we'll do that by first getting the rigid body. So let's create a variable right here that is the rigid body. So it's a rigid body 2D, we'll call it my Rigid Body 2D. And previously we've used, we call this a public variable and we've added from the Inspector. But now I'm going to teach you a much better and maybe more efficient way to do that and coat. The way we're going to do that is in start, we are going to call our variable. And we are going to assign to it the rigid body that is currently sitting on our player game object. So we'll use get component, which gets a certain component. And that component is, well, it's a rigid body to d. And that is how it's written. Now we have a reference to our rigid body, to the, let's go ahead and change it and run. So we'll click on here. It's my Rigid Body 2D. But before that, create a variable for our place velocity. And that variable is going to be a vector two. We'll call this player velocity. Velocity. And display or velocity will be equal to a new vector two. And we'll move, we are moving in the horizontal axis. So we will only be changing the velocity in the x or horizontal direction. So this will add the controls throw to the x axis and 240 y will simply keep it as my rigid body dot velocity dot y. So in the y direction, the velocity will not change. And finally, we'll assign the my Rigid Body 2D dot velocity will be equal to the player velocity that we've currently created. So save that. Let's go back into Unity and see if we did anything correctly. So click on here, are player falls. If you move left, he slowly moves to the left. And if we move right, he also slowly, very slowly moves to the right. O k. Excellent. As you've seen, he moves very slowly and we'll need to fix that. And in order to do that, we are going to create here a variable for the Ron speed. So let's go ahead and create something we call a serialized field who very scary. Some fancy words you using Michel. Don't worry, I'll explain what that is. And serialized field is just like public, where we can change the variable from our Inspector. But the only difference is that we can actually manipulate that variable from a different script. Okay, so we use public functions to change, to use functions from different scripts, we can actually use serialized field to change variables. And I don't think we'll be using it too much, but let's say, for example, you want to change your player speed, for example, depending on the platform you're standing on, you can go ahead and do that using the serialized field. Ok, small explanation. Let's continue. We're going to make this run speed a float, and we'll call this simply around speed. And what should the strand speed B. We can actually do something. Let's try ten. And we are going to multiply it with the controls row right here. So R1 speed, not Trump, actually ran Speed. And now, if we go back into Unity and click on inspector and click on player, now we can see that we have a rents run speed of ten. So we go into play mode. We can move now with a speed of ten and we can actually increase this to 100 C. What happens? And our player, what did you see that you see what just happened? Do you see how our player disappeared? But actually you can still see him right here in the bottom left corner. Don't worry about that. We'll see a couple of more instances of this, but we'll be fixing it later on in the other videos, so I hope you enjoy it. This is the part where our player comes to life and we start manipulating him using code and everything is fun. Everything is very cool. I hope you enjoy it and I'll see you in the next video. 23. Flipping Our Players Sprite: Welcome back everyone. Our player now moves in the game. But the problem is that he does a moon walk. So whenever we are moving backwards, he does not flip p simply does a moon walk. And we don't want that. In this video, we are going to be flipping out players or if we click on play, we can see that whenever we move to the right, we move right. But when we start moving to the left, we actually flip our player. And now he moves into direction and actually looks in the direction he's moving, the correct one. So very exciting. Let's not waste any time and let's jump in and get started. Okay, so how are we going to flip out layer in the direction that he is moving? First thing we're going to do is we're going to apply all of our changes to the prefab. So if we look closely at our player, we can see that he moves left and right, but he does not flip. How are we going to go about this? If you go up into our transform, you can see that we have position, rotation and scale. So scale, if we increase the scale of our player in the x-direction, you can see that he gets bigger and bigger and flatter and flatter. But if we reduce it 2.30, He gets smaller. But what happens if we go beyond the 0? If you go to minus territory, we can see that our player flips. So at minus1, our player is facing the other direction. And this is what we are going to be doing. But in our code, depending on the direction our player is heading in. And we'll do that using math, but not very hard math. If you don't like math, it will be simple math. Oh, okay, so now let's go into our Visual Studio and let's go ahead and create a function that we'll call private void. Philip, sprite, script, sprite. So we have flips bright and we are ready to go. So flips right? Before we started, I need to explain two concepts. First of all, math dot apps. So I hope you remember from school what absolute value means. It means it returns the absolute value of something. So for example, if we have math dot abs minus four, it returns four and math dot sine. So what is not signed? It returns the sign of a certain number. That means if we have math sine minus four, we have minus one as a result. And if we have metal signs for, we have plus one as a result. So this is a quick overview of overview of first grade math or something like that. Let's go back and let's go ahead and create a Boolean. So go into Visual Studio. So n this, we are going to create a boolean which will tell us if our player is actually moving. So let's go ahead and create a board which will be running hoary, long, running horizontally. But sure if horizontally takes two hours or just one, or actually hurries on the a is not in the right place or K. So horizontally equals math dot absolute value, my rigid body to the dot velocity dot x. Now you might be wondering why are we even using the absolute value of our rigid bodies velocity? Well, because we are moving in the left direction, our velocity is negative. And we are, when we are moving in the right direction of our velocity is positive. So we need to take the absolute value to make sure that we always know when our player is moving. And to make this Boolean, because right now it's not boolean. We're going to check if it's bigger than, wait for it. Math, f dot epsilon o k. Now, again, Michelle, earlier using very scary words. What is math dot epsilon. So first of all, when we type math.pi f, that means we are accessing the library of math where we have a lot of functions and a lot of methods, tools. And epsilon is not a method nor is it an function. It's a, a small number, a very, very, very small number, like say for 04 or five zeros after it and one. So why are we using math.pi epsilon y not simply compared with velocity equals 0? If you remember in the previous video when we tried to print the control throw, you can remember whenever we went to the left, it's slowly moved from 0 to minus one. And then it went back to minus 0.00009. It never went back to absolute 0. That's why we're using math f dot epsilon instead of simply using 0. Next thing we're going to do is we're going to use an if condition. So if running horizontally and inside this if condition, I'm going to issue you a challenge. Your challenge is to complete the if statement. So we are going to flip our Player sprite based on the direction they are moving. And let's, I'll give you a couple of hands. One will use Transform dot local scale, and that's how you access the scale of a game object. And you will be using, use math F dot sine to determine the direction in which our player is moving. So pause the video right now, give it your full concentration, your full thinking ability, and do the challenge. I'll see you in a bit. Okay, welcome back. So what should we write inside of our if condition? So its transform? Because we need access to AAC transforms local scale. And this local scale in fact, is a vector too, because it's 2D. So we'll be using the scale on the x and y. So send new vector two. And what should be right for the x and the Y scale should stay the same. That means it's going to be one F uppercase. But what should the XP, while the X will be depending the pendant on the direction. So we're going to write meth F dot sine because it depends on the sign of the direction. And what direction is that? It's not my rigid body dot velocity dot x. So now save that. So now if our player is moving to the right, the velocity will be positive, the sign will be positive, our scale will stay one. But if the players velocities to the left, that means the velocity is negative. That means the sign is minus1, and that means that our local scale, x will be minus one. So let's see if that works. Save that and a small mini challenge I'm going to give you right now. Where do we actually use this flip sprite? Where should we put it inside of our code to flip our player? I'll give you a second to think about it. One Mississippi, two, Mississippi, three, Mississippi. Ok, time's up. It's inside of R1 because we're only be using the flip sprite whenever we are. Product. Save that, go back into Unity. Let's move out of the camera. Click on play. And now if we move right, move right. If we click on the left arrow, we actually flip. And how cool is that? Oh, okay, great. So I hope you enjoyed the video. I hope you did the challenge and I'll see you in the next one. 24. How To Trigger Animations From Code: Welcome back everyone to a brand new video. And this video we are going to be changing our players state from our code. So as you can see right now, we have our player in the idling, idling state as soon as we start the game. And if we move him left or right, you can see that his state changes into running. And if we stop, he changes back into the idling state. So let's not waste any more time and let's get started. Okay, so let's start off first of all, by re-explaining what is happening in our animator. First off, we'll make it a bit bigger and zoom. And so first thing we'll need to take notes off is here in entry. From entry we have a transition directly into idling. And what this means is that as soon as our game starts, we go directly into the idling animation. And from there we have two options or two states to go to. We have the running state and we have the climbing state, and both have transition to and from. So for example, to go from idling into climbing, we can see that we have this white arrow line that has a condition on it. And that condition is for a Boolean to be a Boolean called the climbing to be true. And in order to go back from the Comte climbing state or animation, this climbing, a condition needs to be false. And the same holds true for running. So the transition from idling into running needs for a certain boolean to be true and to go back from the running state, we need a certain variable or parameter which is running to be false. So how are we going to do that using our code? Well, first of all, because the parameters are present on our animator, what we need to do is get a reference to our enemies. So let's go into Visual Studio and tried to do just that. So here we are in our Visual Studio. First thing we'll need is a reference to our animator. And we'll do that the same way we've done to get a reference to our rigid body. So let's go ahead and create a variable for our enemies. So we'll create an NA metal. And he may talk please. So an animator will call this my animator. And we'll use the get component to get a reference to our animator. So get component animator and close that up. Save that. Great. So now we have a referenced our enemies. Next thing we'll need to do. First, we'll be focusing on the running. So how will we change from a idling, whereas that, so from idling into running, how are we going to change that? Well, we'll have to set the boolean because we know that it is a boolean. Let's go back and n running. When we. Start to run. Let's go ahead and go into the running state. So we'll do that by using my animator, which is our reference dot. And it has multiple methods attached to it. And one of them is the set Bool, and this allows us to send it a reference. Actually, it has two ways of giving parameters. The second way is our way, which gives it a string and the boolean value that we wanted to have, the String reference name and the bool value which can be either true or false. So let's do that. First thing we'll need the string name. And because it's a string reference will simply go back into Unity, double-click and copy that reference. Because as we know, whenever we have a string reference, we always, always go and copy it. And now we need to set the value for it. And of course it's going to be true. Now this is not the final solution by any means, but this will demonstrate how the set pool in my animator works. So let's go back into Unity and see if that worked. If we click on play right here, our player goes into the running animation. It's good. It's not bad. At least we know it's working, but this is not how we wanted. We wanted to go back to idling whenever we stop the running state. So that is going to be your challenge. And your challenge is to stop the running animation. So you need to add to our run method a way to stop the running animation. And that means going back to the idling. So it should stay true while the player is running and false when the player stops. Use the code we've created when flipping the spot. So pause the video right now and go ahead and do the challenge. Okay, welcome back. So how did you get on with that? I hope it wasn't very hot or I hope it was at least a bit challenging. So let's see what we need to do. Well, because I've told you will need to use something from the flips bright method. We are going to check if our player is actually running. And we'll do that by simply copying the following line, which checks if our player has a velocity on the horizontal plane. So now we have a boolean for running horizontally. And what we can do, because this is actually a boolean and it's true whenever the player is running and false if the player is not running, we can directly set it right here and our animator. So liver replace that with no, sorry, I mean, running, running horizontally. And let's do one more step. And that is extracting this method, method and to an outside one because it's just a bit different. We'll call this changing to running state. And now we save all of that. We have a changing to running state which checks if our player is moving in the horizontal plane and if he is, that means our running horizontally is true. That means our animator sets the running to true. And if he's not running, this running horizontal will be false. And hence, our animator will suddenly be running to false. So let's go ahead and see if that worked. Click on play. Our player is initially in the idling animation or state. And now if we move to the left, he starts his running. If we stop, he stops and goes back into idling, go rate. So this is the foundation of controlling our animations from our code. We set up our state machine. We have parameters which we can access in our code. When a particular thing happens, we can manipulate those parameters using our code and changing the player state. I hope you enjoyed the video and I'll see you in the next one. 25. Adding The Ability To JUMP!: Welcome back, my favorite game developers. In this video, we are going to add the ability to or player two jumps. So as you can see, he can now reach platforms that were unattainable before. And he can jump from one platform to the other. And as you can see, it's very snappy, is very exciting and it's going to be very, very fun. So let's not waste any more time and let's jump in and gets k's. So first, I want to talk about the jumping mechanics and how they are. So the jumping mechanics will be a bit different than the running mechanics. Why is that? Well, because running is different than jumping. Because when we run we actually pick up speed slowly. But when we jump, we technically immediately have a velocity upwards. So I just want to show you how our velocity actually increments. So if we print the layer velocity to our console right now, let's go ahead and try that. As we start to run without player, you can see that it's 00 when we start running to the right at increments slowly from 0 to 9.79.8 and eventually to ten, then goes back to 0. And the same goes for when we click on the left arrow. But we don't want that our game. We actually want our players to immediately jump as soon as we press the space bar or whatever button we would like to be processed. And we'll do that using a different kind of function than the get access will be using the input dot get button. So if you read the description right here, you can see that it returns a true. So it's a Boolean, it returns a true during the flame, the user pressed down the virtual button identified as birth_name. Anyways, what you need to take out of this is that it immediately turns something into true and then back to false if we press a button, and that's what we're going to use. And of course instead of input will be using cross platform input manager. Because as we, as we said before, we want this to be a multi-platform game. And let's jump in and get started with it. So first thing we'll do is we'll remove this parent because it's done its job, it's finished service. And we're going to create a function or a method right here, which we'll call simply jump. And now if we save that, we have the option to extract. We have this little light bulb lightbulb on the left. Click on it and click on generate method. Don't worry about whatever is written already inside of it. It's a private void method just as we want. So what are we going to do? Well, first thing we're going to do is we're going to use a oil, create a boolean. Boolean is going to be called, is jumping and that is jumping is going to get an input from the cross platform input manager. And we'll use the function that we just described, the get button down. So let's open, they're open it up and we can see that it takes a string reference as an input. So let's go ahead and find the string reference of the jumping and put. We go into project settings that is docked here on the right. So click on that, make this a bit bigger. And let's scroll down and see where we have the jump. There it is. So it's Jump and it's positive button is space. So let's copy this because it's a string reference. And as we've said before, whenever we have a string reference, we always, always, always go and copy it. So now we have the is jumping Boolean set and ready. Next thing we need to do is we'll need to add velocity to our player in the y-direction. So let's go ahead and do that. So we'll create an if condition. And if is jumping. That means if our player has pressed the jumping button will create a vector. Two will name this jump velocity. And this jump velocity will be equal to a new vector two. And in the x-direction will only have my, I'm in my rigid body. So my Rigid Body 2D dot velocity dot x. And in the y direction, we will want to add a velocity, a speed for jumping. And this will be dependent on your preference. It could be five, could be ten, it could be 20. And whenever we have such a variable, when we have something that is variable, it's much better to create a variable for it, just as we did here below for the running speed. So let's go to the top and create a serialized field. And serialized field is something that we can adjust from different scripts. Maybe we won't need it right now, but let's just go ahead and make it a serialized field. So it say float, float, and we're going to call it jump speed. And initially let's go ahead and make it 1515 F because it's a float. So 15 F. And let's add it to our jump velocity. Okay, great. And as a final step, we need to add this velocity, jump, my rigid body dot velocity. Velocity is equal to our jump. Jump. Velocity. Oh, okay, great. So save that. Let's go back into Unity and see if that worked. Make this a bit smaller. Click on play. And now we move left and right. And if we press the space button, we can see that we jump. But that jump is a bit floaty as you can see, but at least say start. It's a huge leap forward in our game development. Surely get it, leap forward. Okay, i will not make that joke again. So let's see what we can do in order to make this game a bit more snappy. So we can see here that we have a physics 2D option and our project settings. And what this allows us to do is allows us to adjust the physics 2D of our Unity engine. And we have many, many options to adjust. We have maximum rotation speed, we have translation speed, we have angular corrections. We have a lot of stuff in here. I will leave a link in the resources to go check out the physics 2D in the unity documentation, you can go into every single detail that you want. But for now we're only interested in the gravity right here. As you can see, our gravity currently in the x direction is 0. In the y direction, it's minus 9.81, which is exactly the same gravity that we have here on our planet. So if we click on play and we jump, we can actually adjust this right here. So if we make it, for example, minus 27, now if we jump, we don't jump as high as we did before. So this is where we begin to tune our jump depending on how high and how snappy we want our game to be. And a small reminder whenever we finish adjusting something in our play mode, if we unclick from play, see that it goes back to its original value. So keep that in mind because you need to remember the value that you chose when you were in play mode. And that takes us right into our challenge and our challenge, or your challenge is to adjust your jumping. So June the gravity and jump speed to make jumping mechanic to your taste. And base your tuning on how many tiles you want your player to be able to jump. So you can either make it totals three tiles, you can make him the best and highest jumper and the entire world. It solely depends on your preference and how you want to make your gain feed. So, pause the video right now and go ahead and do the challenge. Okay, welcome back. I hope that wasn't too hard. I hope you enjoy that type of challenge. So let's click on play and see what our player does. So we move left and right and we'd jump. And that jump is a bit too. Nausea think. So let's make this gravity 100 and now it's a bit more snappy. And in order to help our player Champollion, let's click on player, go to its inspector and let's make the jump speed. I think 50. So let's see 50. Now our player jumps and you can see that he actually disappears below the platform, which is not good. And we face this problem before, as you can remember from, I think it was when we added the Iran speak to him. So we need to fix that before we continue. I don't know if you face this kind of problem while doing the challenge. I hope you didn't. And it's not very hard actually. If we go into our players rigid body, you can see right here that we have something called Collision Detection. And it's currently on discrete. And if we click on the list, we can see that we have another option which is continuous, and this is what we are going to choose for all player. Now what does that mean? Well, discreet is it checks for collisions every certain amount of time while continuous is, as it says, it's continuously checking for collisions every, I think microsecond or millisecond, I'm not sure, but discrete is, for example, every one or two seconds it checks for a collision. And the continuous checks constantly, constantly for collisions. Now why do we have the discrete option? Because we might not have a body that it's very fast or for example, a slow moving bird or something that will not need a continuous collision with things around it. But if we have something like our player, for example, right here that has a gravity that is 100. He falls right through our world. So we'll make it continuous. Continuous is a bit more heavy on the processor of unity, but it's okay, we can handle that, I'm sure. So click on apply, go back into projects. That's make this, let's make this gravity 200 because I think we need it to be 200. Let's make the jump speed 50. Save that, go back into play mode and see if that feels nice. It does feel nice. So let's see. I think it might need snapping to the ground. I think the gravity's perfect. Let's see if we want to make I think that's enough. I think 54 a jump speed is perfect. So I hope you tune that to your preference. You don't have to make it just like me. You can have it whatever we want. It's your game, it's your preferences and see you in the next video. 26. Tweaking Jumping Using IsTouchingLayers(): Welcome back everyone to a brand new video. And in this one, we are going to be fixing our jumping mechanics. So as you remember, maybe in the previous video, whenever we try to jump without player, we could double jump and triple jump and jump into infinity. But in this video we are fixing all of that. And now our player only jumps when he's touching the foreground. So if we tried to jump multiple times, we can only do with once. And that is more realistic, that is more favorable. And I'll see you in a bit. Okay, so what we want is we want our players to jump only when we're touching the foreground. So fright. Now, if we use our player, we can jump multiple times, which is not good. We want only to be able to jump whenever we are touching the foreground. And we'll do that using layers. So if we go into our foreground, we can actually see that we have layer right here in the default, and actually everything is currently in default, but we will be changing that. So first thing we'll do is we go into the layer, click on here, and you can see that we have this add layer right here. When we click on that, we have the option to add a lot of layers. So first thing we'll do is we'll create a layer and we'll call it ground. And now we have a ground layer. Now what's the difference between a layer, a sorting layer and layer and tax. Well, layers are used whenever we have multiple types of, let's say collisions when we want to control what collides with another thing and how the physics of different objects interact with you travel. A sorting layer is used for rendering things based on what sorting layer they are on. So if you want, for example, we've used the sorting layer to render the background behind the foreground and behind the player. And finally, tags are just an extra step of organization. Four layers, they are used in the code. If we have, let's say the player may be, may have, a layer, will have a layer for the player of course. And if he has a layer, may be we want him to interact with different objects in different ways, and that's where we use tex. Okay, so let's demonstrate how the slayer works. If we go into camera, you can see that we have something here called calling mask, which renders everything. We can actually turn that off, turn off the ground. And oh, we didn't assign the ground to the foreground. Now foreground has, is on the ground level, on the ground layer. Save that, go back into camera, go back into the game view. And we can see that everything under the ground layer, which is our foreground right now, does not render. And if we turn that back on, we can see that we can see the foreground again. Okay? So. Now we need a way for our players to know that we are touching the ground layer. And of course we'll be using that through the collider because the collider is the main thing that holds our player on the foreground. And we're going to do that using something called a collider to d dot is touching layer. So what does this function do? Well, it returns a Boolean whenever this collider, Collider 2D, which will be the player collider, is touching any collider on this specific layer mask. So what is this layer mask? It's some, it's an integer that is put inside of touching layer. And it tells us which layer we are. So how are we going to use this layer mask? While we thankfully have a function which is called Layer Mask dot get mask. And this allows us to actually write or get a string reference of the layers name. And it returns an integer, the Layer Mask created from the layer name. So we get our layer name. We put inside of layer mask. We use it for, we put inside of the ghetto mask that is used by the Layer Mask. And we put all of that and sat inside of is touching layer to be used by the collider. So we'll do something a bit different right now because it's time for your challenge. And your challenge is to stop the Maltese jumping. So you'll need to use the collider 2D dot is touching layers. You'll need to use the Layer Mask dot GetMax, layer names which should be ground. That's a small hand. And we will have to complete the logic and stop the player from multi jumping. So I know this challenge, but early I haven't showed you how it's done, but I've given you all the resources you'll need, and I've given you all the examples and methods. So pause the video right now and give this challenge ego. Kay, welcome back. How did you get on that? So first thing we'll need is we'll need to go into our Visual Studio. And before we get started, I know I've told you actually that will need a reference for our collider because colliders are the components that use the destruction layer. So let's go ahead and get a reference for our collider. We know that our player has a box collider on him. So let's do that. Let's create a variable that is a Box Collider 2D t. And we'll call this my Box Collider 2D. And we'll use in the Start, My Box Collider 2D will be the component Box Collider 2D that is on the Player O K grid. Now, why is it telling me that? Oh I typed in my rigid body by mistake, excuse me. So it's my Box Collider, 2D or k. Great. So now what we'll need to do is we need to prevent this jumping method to execute unless we are touching the ground. So how are we going to do that? We'll do that using an if condition. So, so first thing, let's type in if and open the brackets and what should we write inside of it? So we'll need to write inside of it. My Box Collider 2D dot is touching layers. And inside of this touching layers, we'll write layer mask because as you see it's asking us for a layer mask. We type in Layer Mask, dot, get Mask, and open the brackets. And now you can see that it's asking us for a string reference. And I can already hear you. You're telling me that if we have a string reference, we need to go into Unity and copy it. So I will do, as you ask, we go into the layers, we copy the ground even though it's a very easy word, but you have to get in the happen of doing it. So now we open the brackets and what should be right inside of it? Well, let's see. We can do this two ways. First of all, we can take all of this code in here and put it inside of these two brackets. And whenever we are touching, the ground layer will execute the code. But there is a different way and a much smoother way. So that way is, first of all, we'll add an exclamation mark just behind this statement. And what this what this exclamation mark does, it negates whatever is in front of it? The condition inside of this one is false. It will execute whatever is inside of the curly brackets. So let's say we are not touching the ground. That means that this is touching layer returns false. And because we have an exclamation mark right behind it, it makes this whole statement is true and it executes something inside these brackets. And what is inside these brackets? It's something that you've never seen before. Maybe, maybe you do, but it will actually return. We've used return before in the previous section. And what this return, those without anything, actually takes us out of our jump method. So whenever we write return without anything next to it, it simply just jumps out of the jump function and it continues in the update or wherever, wherever it wants to continue. So save that. And let's see if that actually works. So let's get back and to our unity and click on player. That's means smaller. Click on play. And now while we move, we move, we jump. But if we double jump, we cannot double jump anymore because we are not currently touching the ground. But there is a problem here. As you can see, we get stuck in the wall. So if I go next to a wall and I continue to click on the left button, you can see that the left arrow, you can see that we are stuck to the wall and will fix this problem later. Another thing is that we have double jumping. If we are touching a wall and that is not desirable, we'll fix that in the next video because this one is getting a bit too long. I'll see you in the next one. 27. How To Prevent Wall Jumping: Welcome back everyone to another video. So as you can see here, whenever we click on play, we have two problems without player. First of all, if we jumped next to a wall and keep on pressing the left arrow or the a button. We can see that he keeps getting stuck on the wall. That is a problem of friction. And second problem here is that if we can actually double jump on the wall so as you can see, he doesn't touch the ground and yet he can still jump. That is, go and fix this to show this a bit better. So if we go into our tiled pellet, choose the eraser, choose the foreground, erase that. Choose the platform, go to background and actually draw something. Save that back into game. And now you can see that we can double jump on the wall without even touching the ground. So we'll fix that also. Okay? First thing we are going to solve is the friction problem. And to do that, we're going to first of all do the My favorite part of all project creation and that is creating a folder. We'll call this materials. And inside of materials, we are going to right-click and create a physics 2D material. So create that, we'll call this 0 friction. Okay? So I've left in the resources a documentation about physics materials. D you can read all about them, but honestly it's very simple. So if we click on this, we can actually see here in the inspector that we have two options. One of them is friction and the other one is bounciness. So friction is what gets stuck to the wall will put to 0 and bounciness is what makes us bounce. So for example, if you want to add a trampoline to your game, you can create a physics 2D material with bounciness and added to a tramp. Clean. So now let's go into layer. And because we are, we are actually able to do the jump, double jump because of our collider. And if we click on our box collider, we can see here that we have something called material. And this material takes a physics 2D material. So what we're going to do, it's obvious we are going to drag our 0 friction material and put it on the box collider. As you can see, we can also apply that to our prefab. So apply that. And now if we click on play, let's go to our wall and we can still double jump, but we no longer get stuck on the wall. And neither do we get stuck here nor there. We don't get stuck anywhere. Oh, okay, great. So first part of the video is done. The second part is your challenge. Your challenge is to prevent the player from wall jumping. So first of all, you stop the player multi jumping while touching the wall. And I'll give you a hint, which is to add a second collider at the feet of our player. So you have to add a second collider, make it. So that it fits in the feet of our players, need to add a different kind of Collider. I recommend using the polygon collider. And you should make this collider the thing that has to touch the wall. Okay, those are enough fence. Pause the video right now and do the challenge. Okay, welcome back. So I hope you try to do it. So let's get this show started. First thing we're going to do is we're going to add a component. And that component is going to be a polygon collider to d y polygon. Well, because we can make a box out of it. And since we've already YOU, since we're already using a box collider, we can't use that. So right now we are going to edit this polygon collider to make it just at the feet of our player. So let's make this a little bit smaller. And if you want to delete the unnecessary lines, simply hold on, hold on control. And you can see that you can't delete multiple sites. So we'll leave this one. Get the song closer, the swan closer or control delete, delete, that. We don't even need this one. And now we have a box or actually polygon collider right around. Our players fit and make it just a little bit smaller. So, I mean, under the box collider of our players, so make it this big, this big, and that, I think that is enough. Save that and apply it to our peripheral. Oh, okay, great. Now we have a polygon collider on our player. Great, save that. Now, what should we do next? Well next will have to add this polygon collider to our box, or instead of our box collider here. Why is that? Well, because now our polygon collider will no longer touch the walls whenever we want to jump. So in that way he will not do a vulture. First thing we'll need is we'll need to get a reference to our polygon collider. So simply create a variable of polygon collider to the type. We'll call this my layers feet. And we're going to UPS, sorry for that. And we are going to, my players feet will be a component which is a polygon Collider 2D. I want to get, okay, great. So now we have a reference to our players fit that script. And now we're going to change this. So we're going to change the my box collider to my feet, my tears feet. We save that and let's go into Unity and see if that worked. So now if we stand, we can jump, we cannot double jump. And if we go to the wall, we cannot jump on the wall multiple times. Excellent. Oh, okay, great. So I hope you enjoyed this short video and I'll see you in the next one. Everyone, sorry for dropping by, but I thought this is a great opportunity to remind you of doing something very important and that is committing our changes. So as you can see, I've been committing my changes constantly. So I will stage all right now and will commit this change, changes. I'll call it dropped the friction to 0 and prevented wall jumping. Great. So I hope you are doing your part of the job of always saving and committing your work. I'll see you in the next one. 28. How To Add Climbing Mechanics: Welcome back everyone to a brand new video, and this will probably be the longest video in the series. So, but it's going to be worth it because when we click on play, as you can see here, we have those sheets and those sheets actually help us climb on our well in our environment. And because of it, there are places that were previously unreachable like that surface over there that we can now climb on our sheets. It's very fun. It's very cool. And I want you to not get very frustrated with the length of this video. I'll see you in a okay, so first thing we're going to do is we're going to be importing sprites. So let's just go ahead into declarations or unclear resources. Get the declarations and put them inside of sprites. And let's go ahead and create a folder. We'll call this folder terrain. Why not click on declarations or know that scholars. And by Ron meant, I hope I've typed that correctly, put them in an environment and let's slice up our spreadsheets. So make this 30 to make this multiple. I'm sure you're already very familiar with what we're doing. We've done multiple times and we are going to slice it up. So go ahead and click on sliced up grid, grid, cell size. So 32 by 32 and slice that baby up. Okay, great. Now or click on Apply. And I'm not sure if those are called drapes or they called Hanging cheats or I don't, I'm not sure. You can call them whatever you want. Save that. And by the way, we're using it because I didn't find any other sprites. Well, actually free the other sprites. But that's okay. Let's go back. We'll use whatever we have at hand. And it actually makes a more fun game. So now it's time for a challenge. So I want you to finish the climbing. First thing you need to do is setup the climbing tile map with its layers. And by the way, this is a mega challenge. And then you'll need to create a climb method. You'll need to check if our player is touching the climb Bing layer. And you will need to add a climbing velocity to the y-axis using the get access method. Finally, you will need to trigger the climbing animation while our player is climbing. Now, this is a huge challenge. It's the biggest challenge we've done so far. So if you feel a little bit overwhelmed, you can start and then pause and then start again. Or you can watch me do the challenge. And whenever you feel like you have everything under control, simply pause the video and continue on. I'll give you your time. So pause the video right now and go do the mega challenge. Okay, welcome back. How did you get around that? So let's talk. First thing we need to do is we need to add. Toils in here. So let's click on the drapes that we need and select them. Hold Control. Oh, sorry for that. So hold control and select the things that we need. Drag him into our scene. It will ask us to create these styles. So let's go into tiles. They are terrain, No, they're not terrain tiles will create a new folder and these will be the climate goals. I hope climate is written correctly, so Climb mumbles, and now we have them in our palate. So let's go ahead and edit this. Edit, please. So now we select, well, with second, select this one and we're going to move it here and put it just over the our other Tiles. Click again on lacked to move them and save that. And now we have the ability to draw our drips. Cool. Now, let's try that for a second. Oh, and before we do that, let's go ahead and create a tile mapping grid. I mean a tile map. So 2D object, tile map, and we'll call this tile map goto specter. We'll call this tile map climbing. Excellent. Now, back to palette. Click on climbing. It's already clicked and now we can draw it, but not in our scene. Before we do that, I want to create a small platform. So let's go ahead and to foreground. Let's choose two of them and we'll delete it because I don't want this here right now. Let's go back to background, finishes that. And let's see. I want to make a bit of editing in here, so I will maybe speed this video up. Oh, okay, welcome back. So let's continue. So as you can see, I've created this platform right here that our player can get too while jumping. We can only get to there using our special drapes. So that's going to climbing and let's add our drapes. And as you can see, we cannot see them. So we'll change that by creating some layers for our rates. Go into add layer. And let's create here a layer for climbing. No, it's not the sorting layer, but we'll use that also to touch our drapes. And we'll create a layer for the sorting layer. And now we have it rendering in front of the background, but behind the player. Excellent save that, go back to climbing, go into the inspector, Click on the tile map renderer, and in the sorting layer make this climbing. And now we can see it perfectly. And also let's make the layer on the climbing rate. Another thing we should do is we should add a collider. So let's go ahead and add a box collider to it. And let's see, this collider is 100% wrong. Let's make it smaller and smaller. And zoom in and make sure that the surface that the player can touch in order to climb as inside the drapes. So make it like that perfect. And one other thing we should be adding is a composite collider. So Composite COM ports Collider 2D. And we'll make sure that the rigid body is static and that our box collider is used by composite. Save that. Oh, okay, excellent job. Let's continue on. Next thing we'll need to do is we'll need to create a function for declining. Because as of right now and we cannot climb anything. So if I click on play, our player simply bumps into our hanging cheats. And another thing we need to do is we need to make sure that our composite collider right here is a trigger. And what this does it, it can be used as a collider, but we can't actually collide with. So for example, if we jump on it, oh, actually I'll play or maybe can't get to that. Oh, no, he can't. So he doesn't need the ladder. Great. So as you can see, our player does not collide with the drapes. Save that. And next thing we're going to do is we're going to go into our Visual Studio and go ahead and create our climb function or method. And we'll generate that. So we have a climb function which is private and doesn't return anything. First thing we're going to do is we're going to check if we are touching the climbing layer. So we've done that already and will use my players fit. I would rather use my feet to climb. So as touching layers, layer mask and the Layer Mask or use the get mass component and it needs a string reference. That means, even though we know that climbing is very easy to write, We'll go back, copy it, and paste it inside of here. And we won't be using the same method we've used in jump. You will know why very soon. So next thing we're going to do is we're going to use the get access. And if you feel that you can continue to challenge at this point, simply pause the video, check the challenge again and see what you need to do and completed on yourself. So pause the video. Okay, we're back. So let's go get the axis. So well, be used the same method as we used for the running. So we'll create a float that is called control throw. And we'll use the cross platform input manager, dot. Get axes, and this time it should be on the vertical. So let's go see what? Oops, this is a challenge again for you. So let's go see in our project settings and whereas the inputs, input manager check the vertical and let's see the US and W. Copy the vertical, go back and to unity and I'm in Visual Studio and pace that, great. Next thing we'll need to create a climbing velocity to add to our player. So go ahead and do that. It's exactly the same as for running, but now it's climbing velocity. So climbing velocity is equal to a new vector two. So now what we need to do this, we'll need to add a velocity in the y direction, but keep the x-direction velocity the same. So we will go into my rigid body two d dot velocity dot x. So this velocity will stay the same, by the way, if you want to try it, you can actually make the velocity on the x 0. So that way whenever our player actually touches the drapes, he gets stuck there and he cannot move anymore, which is a bit more logical. But because this is again, I think I'll keep it velocity x, feel free to make it 0 f. And next thing we're going to do is we're going to add a control throw in the y direction. But we already know that that will be too slow. So we are going to create a variable right here. And of course it's going to be a serialized field. It's going to be a float and it's going to be climbing speed. And our climbing speech should be, I think 8.5. It is a good climbing speed. So control throw will multiply that with our climbing speed. Close that final step. My Rigid Body 2D dot velocity will be equal to the climbing. Nope, I mean, I meant climbing velocity. Thank you. Close the semicolon. Always remember to close the semi-colons. And now we've said everything. What else do we need to do? We need to check if something actually worked. That's confidence for you. So save that everything is saved and click on play. And now we can move around. If we jump, if we jump, we can now climb and if we let our player drop, he actually falls down from the drips. Oh, okay, excellent. One thing I want to do is I want to make this a little bit longer. So that's a little bit longer, just like that, we can even make them touch the ground, which becomes sort of like a ladder. Actually exactly like a ladder. So go back and check this. Click on play. Let's see our player an action. He touches the drapes and he can not. Ok, he needs a little bit of a push in order to jump on this. That's because our collider is not touching the feet of the player. Let's change that. Let's go into inspector and make the box collider just a little bit bigger. Oh, oh, Talk Box Collider didn't go with the climbing. That's unfortunate. That should be corrected but no worries right now. Saved that. Click on play. And now we should be able to climb. Oh, okay, great job. Let's now final step will need to add the climbing animation whenever we are on the drapes or whenever we are climbing. So in order to do that, it's super simple. We already have the reference for our animator and we already have a boolean for the climbing. So as we did before, I'll give you another chance to complete this because it's very easy. Pause the video. No, you want to watch me do it ok, so my animator, so my animator dot set Bool. When we are actually touching, we're always going to be in the a climbing animation. So we'll go ahead and get the string reference. Copy that, go back to visual studio based. And it's going to be true. And when we're outside of the if condition. So whenever our player is not touching the sheets anymore, he can actually go ahead and stop the animation, which means setting the climbing back to hope what happened there and setting back the climbing to false. Save that. That was a long video. Okay, so click on play. And now our player gets stuck to the drape and goes into the climbing animation. And let's try this again. And actually you can see that he hangs on the drip. Now, one thing we'll fix about these is when our player actually touches these drapes, I want him to get stuck to them and not drop down every time. We'll do that in the next video because this one is getting too long and I'll see you in that one. 29. Tweaking Climbing Mechanics: Okay, so a couple of things that we need to change in here. First thing we're going to change is we're going to go into our sprites and go into our sprites editor. And if you go here to the upper left corner, you can see that we can actually customize the physics shape. And this is the first thing that we're going to do to our trips. So we click on Generate and we can actually change the outline of our box collider that we are going to add. Why are we doing this? Well, because I actually want our player to only be able to climb if he's actually holding and touching the drapes. So make them just inside this inside the drapes. It will help you. It will snap to place. So click on whatever sprite that you want and click on the generate button right here and get them a bit closer to the center. That way they will move and actually feel more, a bit more realistic. So not that much. So that's go ahead and keep these inside. We can actually even this one to it. You don't have to be that accurate. But if you want to be that accurate, Yukon and everything is good, this one's good, this one's good, this one's good. Click on Apply and we're ready to continue. And now I've made a mistake, a small stake previously, and I've added a box collider. So we'll have to remove that component and actually add a tile map collider to D And make sure that it is used by composite. So check that. And the composite should be is trigger. Okay, great, Save that. Next thing we're going to do, because through trial and error, I found out that actually using the feet for climbing is not a good idea. So let's go ahead and change it into, nope, into my box collider, and that will be better. So everything should be fine except for one thing. And if we click on play and we jumped on our drape, we can see that our player slowly starts moving down a free let off the w or the up arrow key. And that is where your challenge comes in. And your challenge is to stop the player from sliding. So first thing you need to do is set the gravity on the player's rigid body. And then you need to set the gravity to 0 while the drapes, while the player is on the drapes. So this will need a bit of research, just little bit of research. And I am sure you will be able to finish the challenge. So pause the video right now and go ahead and do your best. Ow, kay, welcome back. So let's get started. Let's get started as starting the video. So if you click on player and look at the rigid body, you can see here that we have something called the gravity scale. And this is if you hover over it, it's how much gravity affects this body. And this is the component that will be manipulating in our code. How are we going to do that? Well, first thing we're going to come here and create a variable that is a float. We'll call this the starting gravity scale. And what will this value be? Well, it's going to be the starting gravity scale or the gravity scale that we start off with. And it's going to be the original cavity scale on my rigid body. So we'll type in start gravity scale. It's equal to my Rigid Body 2D dot the gravity scale. And this will be one of course, but we want to be more precise using my body's gravity scale. Next thing we're going to do is whenever we are actually on the drapes or touching the drapes, we want to set my rigid body dot gravity scale to 0 F. So now whenever our play is touching the climbing mask or the climbing layer, the gravity scale will go to 02 refers that effect will change it back to the gravity scale of starting gravity scale. So if we are touching the climbing layer, my rigid bodies gravity scale is going to become 0 and else so when we are not touching the climbing, our gravity scale will be set back too, the starting gravity scale. So save that, go back into Unity. Wait for it to understand what is happening, and let's click on play and see what happens. So now if we climb up, our player stays on the drapes and doesn't slide down without touching the keyboard. A girl rate. So I hope you enjoyed this quick video and I'll see you in the next one. 30. Cinemachine Follow Camera: Welcome back everyone to a brand new video. And as the title suggests in this video, we are going to make our camera follow our player using something called Cinna machine. So as you can see now, if we move our player, the camera isn't static. It doesn't stand still and wait for us. It moves with us. And even if we climb, it moves with us when we're walking, it moves with us and when we jump at, also goes wherever our player goals. So or as you can see, we have virtual cameras. We've added a brain to our cameras. So now it's actually thinking about things. And I'll see you in just a bit. Okay, so what are some machines and why do we need them? As you can see right now, our player just moves in the environment and the camera does not take notice of him at all. And what we want is we want the camera to actually follow our player as he moves through the level, because we'll be adding a much bigger level that will spend from here and two here, maybe up, maybe down. We don't know, but we want the camera to be following him. Now before Cinna machines, all what you needed to do is you would actually need to create a script and end that's great. Script. Create a serialized field that would get the player and use his transform to go and follow him every step of the way, which was very cumbersome. But now we have the power of cinema machines, correct? So let's start off by importing machines. And in order to do that, you need to go into window up here, here. And you need to go into Package Manager, click on package manager, and go into your Unity registry. And you should have this cinema cine, which is verified right here. And now what you need to do is you will simply need to click here on this install button. It may download something. I've already downloaded the package, so it's simply going to install. Oh, okay, great. Welcome back. So now as you can see right here on the top of our screen, we have something called a sinner machine. Now, what is a cinema machine? Well, a cinema machine is something that allows us to create virtual cameras. We still have our Main Camera. And on that camera we put something called a cinema cine brain. And that brain drives the other virtual cameras that we will be creating. So why we actually use these virtual cameras? Well, in 3D games, these virtual cameras are used to create cutscenes. For example, whatever game you play, whenever you see a cutscene, it's probably because they used a cinema machine or a, I mean a virtual camera. And in our case, for a 2D game, we'll use it to make our game a bit more dynamic. So let's first of all go into our main camera and click on add components. Make the smaller click on add components and simply type in a brain. So now we're going to add a brain to our camera. So cinema cine brain, click on that. And now we have the brain setup right here. Next thing we're going to do is we're going to go into our hierarchy and create an empty game object. And this empty game object, we'll reset. It. Doesn't matter. But I'd just like to reset, Thanks to have them all in one single place. And let's rename this to our cameras or simply type in rows. Okay, and this is for the sake of organizations. Organization. So let's put main camera under our cameras. And now let's go ahead and to send a machine and create a 2D virtual camera. So let's see, we have this create virtual camera, collect on that. And now we have something called a CM, the camp. And if you look to its right, you can see that we have something called here, follow. Now, I've left a link in the resources for everything you need to know about cinema machines. You can go ahead and read the entire document or you can simply just glance over it and get a sense of what things are. So for example, they look at the follow the position blending are very important things. You can look at the lens. There are many, many, many helpful information right here that you can read all about if you don't understand it right now. But let's go back into Unity and focus on the important and main things. So we have this follow and this is the most important part. So it's the object that the camera wants to move with. And that object is of course our player. So simply click on player and drag him into the follow. And now this camera should be following our player. I another thing, because it's somewhat important and it's very dependent on you. It's under lenses, you have something called orthographic size. And this is actually the size of our cameras. So you can make it bigger and you can make it smaller, and it depends on how you want your game to feel. So for example, our main camera, we can see here that we have the size, I think it's 5.02. And for our virtual camera will also be 5.0.2. Let's make it five ergo rate. So now let's go ahead and rename our CMV Cam, which is a very weird name. Let's simply call it VR virtual camera. And we'll put it under cameras. So now we have cameras under a single object right here, and it's much butter. So save that. Let's click on play and see what actually happens. So now as you can see, while moving, move in our world, the camera follows our player. So now it's much more dynamic and it feels. Like a true 2D game. So let's go out from that and let's discuss a couple of things about virtual cameras. Now. If you go here, if you're still clicked on virtual camera and you look in the inspector, you can see right here that we have something on the body which is a transpose. So let's go ahead and change that and make sure that you have it under framing transpose. And you will get all these different weird options right here that we will discuss. But before we do that, go up a bit and you will find that you have another option right here that is called game window guides. If you click on that, you can go into a game and you can see that we have different windows. And each one of those windows has a different effect on our virtual camera and how it uses the environment or how it follows our play. So let's start things and explain a couple of these. There are a lot of options we won't cover all of them. Feel free to go into documentation and read about them if you want to be meticulous with the first thing we have is the look ahead time. So Let's click on play and start the game and start tweaking from him. So if we choose a look ahead time, you can hover over it. It doesn't say anything, but I'll tell you what it does. First thing it does, it actually determines where the player is going to go. So now you can see that this yellow dot, actually that yellow dot represents where our camera is looking at the moment. So we have both of these on 0. You can see that r dot moves with the player, however he goes. But if we add some look ahead time and smooth that out, the yellow dot will precede the player. And it will calculate or determine where the player might be going next and will smooth out the transition of the camera. Next thing we have is we'll have something called the dead zone. And this zone, if we increase the size just a bit, we can see that we will have a zone inside of our guides or window guides. And if we move inside this dead zone, the camera will not move. It will only follow the player if he steps outside the zone and it's determined by this yellow button or yellow dot. So now, let's go here. For example, if we move inside of our dead zone, we do not register or the camera does not move with our player. What else should we talk about? So I think we'll add a bit of that zone right here will make it 0.20.2. Oh, okay. What else should we oh, excuse me. So 0.2 by 0.2, please start whom and what else should we be looking at? We have something called the damping. And let's go ahead and increase. The best way to find out what all of these do is simply by increasing them and trying the game out. So now damping, you can see that it slowly goes to where the player is. Doesn't immediately jump to where he is and put it to 0. You can see that the camera becomes very fast and it actually has its own feel to the game. And all of these can be tweaked to your preference. They can also be made a very extreme, they can be made to 0. It depends on your preference, on how you want to make your game field. And always remember whenever you change things in here, you need to remember them. Remember them because when you click on play again or go out of the play mode, everything will be reset. And now it's time for your challenge. And your challenge is going to be to set up your follow camp. So first thing, you need to tune your, the virtual cameras to your own preference based on how you want your game to feed. And you'll do that using the camera size, using the dead zone size and using the look ahead. So you can pause the video, or it's simply the end of the video. Wait for it to finish and go ahead and set up the virtual cameras to your own preference because it's your game. It's not my game. I do it the way I want and I want you to do with the way you want it to be. So I'll tweak a bit and I'll see you in a bit. Okay, so I'll just make a few changes right here. It's not going to be much output the dead zones to 0.2 in the width and the height. And I'll think, I'll add just a little bit of look ahead with a bit of lookaheads moving and the damping. I think I'll keep it the same. And if we click on play right now, let's see how that feels. If we walk, let's turn off the window guides. So if we turn off the window guides, so as we move, our camera moved was with us. Maybe I'll add a bit more smoothing, so make it three. And it really feels very smoothly. Make this a bit more 0.02 and great, I think this is smooth and cool enough. So I hope you tweak your own virtual cameras to your preference, and I'll see you in the next one. 31. Cinemachine Confiner Extension: Welcome back everyone to a brand new video. And this one, as you can see, we've made a bigger level, which needs a bit more tweaking, but it will work for now. And what we've done is now if we move our camera, as you can see, it moves freely without player. But if we go to the edge, you can see that it no longer moves beyond this edge. That means we've created a world confining. And why did we do that? Well, it will give our game a sense of immersion. And whenever our player climbs, he no longer sees anything beyond the realm of our world combiner. So let's not waste any more time and let's jump in and get started. Okay, so the problem right here, right now is that whenever we play, we can actually see what's going on behind the scenes. So this takes out the emergent from our game and makes our game actually not feel real and feel like it's worked on, it is, but we don't want the player to know that. So we have to change what's happening. What we're going to do is we're going to create a confined around our level. And this confined or will not let our camera move beyond it. So let's do that. If you go into our inspector and scroll down, you can see right here that we have something called extensions. Let's go ahead and add an extension. So click on that. And you can see that we have a lot of options. But what we're going to be needing is this cinema machine con, finer. Click on that. And below it you can see now that we have a new component that's Santa machine confirm finer. And it needs a bounding shape. That is to d. Great. What we're going to do is we're going to be creating a tile map. And that tile map will be our world combiner. And it will stop our camera from moving beyond that. Let's click on File Map. Right-click on that. And let's create a 2D object which is a tile map, will change its name to world confined. And now we have a new tile map setup. If we go into our tile pilot, we should have our WorldCom final. And you can choose to have your pile that represents the word confinement or what ever it is. But I will choose to have it as this center block right here. So let's go ahead and create our world confined there, just around here. Okay, and now we have it set up, but still, this does not work properly, properly. And that's because we still haven't added the bounds for it. So what I'm going to do right now is I am going to make our level just a little bit bigger. And in order to see how this camera actually works, and I'll make this a quick video using the magic of video editing. So see you in just a bit. Okay, welcome back. So as you can see here, I've created a platform. I've increased the size right here. I've added a ladder in order to reach the top and some kind of weird room right here. I'm not sure what it does. And that's basically it. And what I just wanted to accomplish right here is just to make our level bigger to move it. So now let's go ahead back into our tile and choose WorldCom finer and create the confinement around our world. So let's go ahead and do that. Make it this big. And let's go ahead and make it this big right here too. So this depends on how you want it. Don't you don't have to make it exactly the way I am making it. You go ahead and create your own platform and make your own world confined. But what you need to keep focused on is that we need this right here. As you can see, this is the camera that we have and you need to make sure that this camera actually fits. So never create, for example, something that's very small, like like here. And then this doesn't allow our camera to fit between those two spots. So make sure you keep that in mind. So let's control z two times in order to reverse these changes. So next thing we're going to do is we're going to add a polygon collider to our world confined. So let's go ahead and do that. And why are we doing that? Well, because if you look closely into our visual virtual camera down here, you can see that it needs a collider to D that will tell it how it will be confined. And a polygon collider is the perfect way to do that. So as you can see, it's very big and will change that very quickly. Click here on edit. And let's go ahead and add it to our confined. Now this doesn't have to be perfect. You just need to make sure that the green lines are inside of your world combiner tiles. So let's go ahead and make it this big. And we choose a polygon collider because it's very easy to manipulate. So make it this big, and then hold control to delete that. And now we have. A square. Well, it's a polygon, but it's a square. And make sure that the green line or inside this, these tiles, or whatever tiles you've chosen to make the world combiner N. And I think it's great and it's working fine. So save that. And now let's go ahead and add this world confined her to our virtual camera. So click on virtual camera, camera again, go down into the extensions and simply hold down ops, hold down on the world confinement or wait to go back down and hold down the world confined and drag it into the bounding shaped 2D. As you can see now we have this bounding shape. So let's play this and see one thing that is wrong. So now we click on play, and as you can see, our players simply disappeared into the unnatural what's called below there. And why is that? Well, if we click on player and take him into this spot, for example, and click on play again. He's still disappears into a mature even where that is. And why is that? Well, because our player is confused, he's not sure where he should be or what should he be interacting with because our world confining right now has a polygon collider on it and he doesn't know if he should stand on this polygon or should they float on this polygon, he doesn't understand what's happening. And the problem with that is if we go into our project settings, that's close that and go into our physics 2D and expanded. If we look down here, we can see this matrix and what this matrix is. It's, if you read it, it's saying layer collision matrix. So it tells us what layers interact and collide with each other. So for example, you have climbing that interacts with every single layer that is. And for example, default also interacts with every single layer that is a available. And if we look into our player, so go back to Specter. First of all, our world confinement is on the default layer, and our player is on the default layer. That makes them both interact because of this matrix. And to turn that off, you can simply click on this button and it will stop the interaction between those two colliders. And this is where I take you to your challenge. And your challenge is going to be to create a camera confined R. So first thing we need to do if you haven't done so already is create a bigger level for your player and ca