Hello, welcome to this lesson in Unity. In these lessons, you will learn how to use inputs to control the player in Unity. From Unity Hub, open the platformer project. Open the Level 1 scene, if the tile pallet is still open, you can close it. Let's create our player prefab, then learn how to control it using the default Unity inputs. In the Project panel, open the Pixel Adventure 1 folder and the Assets folder. Add Assets, main characters, and then open the Virtual Guy folder. Select the Run, Sprite. You can see in the Inspector, this is an animated strip of sprites, 32 pixels high. Confirm the sprite mode is set to Multiple, and set the pixels per unit to 32. Make sure you click Apply, click the triangle to the right of Run. You can see all the animated sprites in a sequence. A shift select all the sprites, click the first one, shift click the last one, then drag the selection to the hierarchy. Request will pop up, go to your Assets, your main Assets folder, Animations, we'll name this Run. Now select Run, in the hierarchy press F2, and rename this to Player. In the Inspector, change the sorting layer to foreground, this is very important. Open a prefabs folder, drag the player in, the icon turns blue, and now we have a prefab for our player. In the scene panel, move the player to the left. Select Player, in the hierarchy, in the scene panel hit W to move, and click in X and move your player off to the left. Save the scene, now press Play, the player is looping and running motion, but not going anywhere. He's also floating above the ground. The way we will move this player, as well as enable collision detection, is by using Unity's 2D physics system. Stop Play, with the player selected, in the Inspector click Add Component and select Rigid Body 2D. Once adds physics to the player, we also need to define a collision area around the player. Click Add Component again, and search for Box, and we want to add a Box Collider 2D. Be sure to add only 2D components. Right click in the scene panel, and click after the frame of your player, in the Inspector, click Add a Collider. You'll see a bounding box around the player, click the dots in each side of the box to adjust around the player. Click Play, and let's see what happens. The player now falls down with gravity, but it's passing through the ground. We need to add a Special Clider to the ground. Stop Play, throw open Grid, select Foreground, and the Inspector click Add Component and search tile. We need to select the Tile Map Collider 2D, which is a special type of Collider. Let's hit Play again. Now the player lands and stays on the ground. This is a great start. Now we need to add some code to this player in order to use the keyboard to control its movement. Open the Scripts folder, right click and create a new C-sharp script, and name it Player Control. Always remember to name immediately. Check the name of your script matches the public class in the Inspector. Select a player in the hierarchy, and drag this script onto the player. If you don't have enough roomy inspector, you can twirl down and collapse some of the panels. Open the Script, click your cursor after the first curly bracket, and press Enter to make some room. Because this is a physics-based movement, we need to define a rigid body and set a speed variable. So I'm going to type Private, Rigid Body, 2D, and we'll name this variable RB. Press Enter again to make some more room for the next line, and type in Public, Float. We'll name this variable Move Speed, and we'll give it an initial value of 4. Don't forget the letter F after the number 4, because this is a float variable. Public allows us to adjust this variable for the editor. Press Enter again to add some space. Click inside the Start Method, and type RB is equal to Get Component, we want to get component with the brackets, and the bracket is found on your keyboard, if you hit Shift, comma. We're going to type in Rigid Body, 2D, and at the end we're going to add parenthesis and a semicolon. This sets our Rigid Body variable name, RB, to react with the Rigid Body component we added to the player. This allows us to send commands to the RB variable, such as Velocity, which will make our player move in various directions. Save the code, and minimize Visual Studio. Before we continue the code for the player, we need to understand how Unity has the keyboard keys mapped as default inputs. Open Edit, Project Settings, Unleft Column, Select the Input Manager. On the right, you will see a list of axes for the different input types, twirl open axes, and you can see input types such as mouse and keyboard, twirl open horizontal, make a note of the name horizontal, and it starts with a capital H. We need to type this in exactly in code. Further down you can see a negative and positive button, a negative button returns a value of minus 1, and a positive button returns plus 1. This means the left arrow on your keyboard, right is the right arrow. You can also press the A or D keys for the same actions. So basically the horizontal value would change if you press A, D, or the left or right arrow keys. Close the panel, open the Scripts folder, double-click the Player Control Script, and Visual Studio we're going to add a special update method that works better with physics-based movement. Click on the line after the start method, press Enter to make room, then type in void, fixed update, notice that it tells sense we'll automatically set up the parentheses and curly brackets for you. Inside the curly brackets we're going to type in float, move direction, this is a variable making on the fly, equals input, dot, get axis for raw, parentheses, and we need quotation marks, and if you remember, horizontal is spelled with a capital H, you need to spell this properly or else this won't work, and don't forget your semicolon. This creates a variable on the fly that we name move direction and contains the value from the horizontal input. Let's press Enter for new line and type in RB dot velocity equals new vector to parentheses, move direction, which is one of our variables, we're going to multiply that by move speed, place a comma, then end with RB dot velocity dot y, that's velocity up and down in the y direction. Velocity for a 2D game is a vector 2, meaning movement in the x and y direction. The player will travel in the x direction based on a positive or negative move direction multiplied by the move speed. The second value after a comma is the y or up and down value, which for now will stay at zero. Save the script and minimize Visual Studio. Play the level, and now if you press the A or D key or left the right arrow, you can move your player back and forth. This is a good speech for the game, and it looks like we're getting some progress. Save the scene, and in the next lesson we're going to learn how to install the new input system in Unity. Thanks for watching.