Getting Started in Game Development: Make a Moving Player for a Top-Down Game or RPG with Godot | Isaac B. | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Getting Started in Game Development: Make a Moving Player for a Top-Down Game or RPG with Godot

teacher avatar Isaac B., Software and Game Developer

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

9 Lessons (34m)
    • 1. Let's Make a Controller

    • 2. Download Godot and Set Up a Project

    • 3. Keybinding: Bind Keys to Actions

    • 4. Start the Player Scene

    • 5. Make the Game Scene

    • 6. Start Coding with GDScript

    • 7. Implement Vector Math

    • 8. Add a Camera and Some Collision Objects

    • 9. Final Thoughts

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels

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.





About This Class

For those getting started in game development, this short class teaches the basics of character control for top-down and RPG formats, including straight and diagonal movement and speed. Many of these concepts can be applied to other types of games as well!

I will use a free and open source game engine (Godot) for this course. With its new update, Godot is comparable to Unity or Unreal Engine; its purpose is to help us make games by providing frameworks and skeletons most games already need. Plus, since it's MIT-licensed, what you make with it is yours, and you'll never have to pay for a license or any royalties.

Having said that, the logic and understanding you will acquire in this course will be applicable for use in many other engines and frameworks.

 At the end of this class, you’ll be able to create a moving character that the player can control! I can’t wait to check out your work!

This class is geared toward anyone interested in making video games! No prior experience in game development or programming is required, but some experience in Python or scripting could be helpful.

Here’s a brief overview of what this class will teach:

  • Basic vector math
  • Vector normalization
  • Keybinding in Godot
  • “Moving” things in games using Godot
  • Collision in Godot

If you get stuck along the way, the Godot 3 documentation can be very helpful! The Godot Discord channel may also be of use. Of course, feel free to reach out to me for assistance as well!

Here's a tour of Godot!

Here's a link to the Godot Docs of Scenes and Nodes.

Keep learning and check out these similar classes next:

Meet Your Teacher

Teacher Profile Image

Isaac B.

Software and Game Developer


Class Ratings

Expectations Met?
  • 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.

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.


1. Let's Make a Controller: Hello, I'm Isaac. I'm a hobbyist, game developer and gamer. This class teaches the fundamentals of creating character controllers for games. I teach every single step as I go along. So this class is fitting for both beginners and intermediates alike. At the end of the class will have a controllable character who can move around and collide with things for a top down RPG style game. If all goes well, you'll get a lot out of this class along the way, including some skills and vector math vector normalization programming in the language called G script, similar to Python as well, some general understanding of how character controllers work in games. This course will use the good Oh game engine, which is a free and open source engine on par with the likes of unity and on riel, you'll gain some skills that are applicable to those other engines as well. What I like about Goudeau is that it's completely free, and the game that you create with it is yours. Down at the very last line of engine code. I'm already planning other relevant courses to this one on skill share. So do be sure to follow me here on the platform. If you're interested in any of that for a class project, I'll ask you to mark down any major changes in understanding that you have as a result of this class as well as mark down any tweaks you decided to make to our character controller because I'll be giving a lot of opportunities for you to make changes of your own. If you ever get stuck, please don't hesitate to ask for help in the discussion. Tab will be actively monitoring it. Hopefully, other students will be able to help you as well, and our first lesson will down with video game engine and prepare ourselves to start a new project. I'll see you there. 2. Download Godot and Set Up a Project: Hey, guys, welcome to our first lesson. So I guess this whole thing kind of starts with downloading the Goudeau engine. There are a couple of ways we can do this, including getting the engine from steam and your web browser. I'm gonna just download it from our web browser, so I'm gonna go to g o D o T e N g i n e dot org Kiddo engine dot ward, which is the official Goudeau injured website. And once this loads up, you'll see I have a link up here for the download page. I'm gonna go to that page. The Goudeau website automatically detected that I'm using windows and it's offering a 64 bit and a 32 bit version of the engine, so Oh, no. What do I pick? Well, since I'm on windows, I could go right click my desktop. We're going to display settings just as a quick shortcut, then going to about and you can see next to my system type here. I've got my 64 bit operating system, so I know that I will download the 64 bit version of judo. I'm going to press OK to save it if you're not really sure whether your computer is 64 or 32 bit. A good rule of thumb is that newer computers will generally use 64 bit, and older ones will use 32 bit. This isn't like a hard and fast rule, but it's very helpful. Now that the zip file containing the Goudeau engine has finished downloading. I'm going to extract it to my desktop. Alright, so I've extracted the engine of my desktop. You can see it right here in the top left corner. I'm gonna double click it to open it and oh, no, Windows is trying to protect my PC. It says Windows Defender. Smart screen prevented an unrecognized app from starting running, Miss. That might put your PC at risk. Oh, no eso. Since Godeau is open source, you can actually check the source code yourself if you're interested. But I trust good. Oh, so I'm going to press more info and press run anyway when I open up the dough for the first time, it says that I don't currently have any projects and asked me if I'd like to explore the official example projects in the asset library so If you choose to download cadeau from steam instead of from the Web browser, you would already actually have a lot of the official example projects Here. They're helpful templates that you can use if you're looking for organizational guides or co tips. I find them very helpful for learning. They can be a bit overwhelming, though, if you are an absolute beginner, because obviously they are very close to finished projects. So you open it up and just is tons of content in there. I prefer to start from a blank slate and consult the demos if I ever need any help. So I'm going to press cancel and I don't want to open up the Asset Library. This is the Gedo project manager, so this right here will be a list of all our active good of projects. This button will let us edit any active video projects. This will let us run or test our games, scanning our computer for any active video projects that already exist on the machine. New project, which is the button that we are about to click, will allow us to create a new good a project. Of course, this import button will let us import any demos organo products that we dominate from the Internet or just didn't originally have in the computer. The renamed Button will rename our Ghetto Project, but not the actual folder. And the remove button will remove any good oh projects from this list, but again not remove or delete any of the actual folders or files associated with the game . The last thing I wanted to show you is kind of something we already talked about. It's his templates tab. If I click it, it will automatically try to load up a bunch of good oh projects and demos that are already existing for us to download and check out if you want to. I'm gonna go back to the project list and press new project. You can see I've got this window here that says, create a new project or create new project. I can type my project name here, so I'm just gonna type the cranky wizard. It's a very nice dramatic name. Good way to start, and this is the project path. This is where on your computer you'd like to store your game. I'm just gonna put this folder on my desktop, it says, Please choose an empty folder because my desktop isn't empty, it already has files on it. As you can see to solve that, I'm just going to press create folder. And now you can see Goudeau has created a folder called The Cranky Wizard on my Desktop that will basically contain all of our Goudeau project related files. In our next lesson, I'm going to press the screen edit button. But before I go ahead and do that, I'd like you to create your class project here in skill share. I'm not going to ask you to do anything super, gigantic or overwhelming for your class project, like uploading an entire finished Goudeau project. Instead, I'd like you to just write one or two sentences in the class Project field, sort of describing your current knowledge of character controllers and how you think they work at the end of the class will revisit the project and determine how your understanding may have changed. As soon as you've created your project, I'll see you in our next lesson 3. Keybinding: Bind Keys to Actions: Hey, guys. So in this lesson, I'm just going to pick up right where we left off and press this create and edit button to get started on a project you can see we've opened up the Goudeau editor screen right here. Now, instead of info dumping and giving you a giant tour of this engine, I'm just going to be explaining the features we use as we use them. Hopefully, that will make things less overwhelming in a little bit easier to follow. However, if you are interested in a quick overview tour of the engine, I will provide a link to a resource on the widow official docks in the class description that will do just that. In this lesson, we're going to be adding key. Bynes too good does existing input map. Basically, what that means is that we are signing names two groups of keys on our keyboard so that we can more easily reference those keys in code. This will be helpful. One, for example, we want to detect whether the player is pressing the up arrow to try to move forward to get started. With that, I'm going to go up to the top left and press project and then project settings. These are Gatos project settings which basically control how your game is run by Goudeau. So we've got things like boot Splash with splash screen that Goudeau will use when starting up your game The window size basic settings for your game Essentially over here. We've got her input tab. This is where all of our key binds air stored, as I've described earlier. Admittedly, we could probably already use some of these for our purposes like the you I up group, but for learning purposes, we're going to create our own. So in this action field here, I'm going to type the action that I want to create, which will be move underscore up, then gonna press this ad button over here and you can see we've got a new input group right here. Toe add keys to this group. I'm going to press the plus button and then press the key button and then press the up arrow. You can see it shows that I've pressed up and then going to press OK and then going to do the same thing for W on the W A S D pad if people refer the usage of the wst versus the arrow keys and then press, OK, I'm gonna speed up this part of the video, but basically, I'm just going to do the same thing for down left and right as well. All right, so now I've added all of my key bind groups to the good oh, project settings, input map. That's it for this lesson. So I'm going to press clothes and I will see you in the next one. 4. Start the Player Scene: in this. Listen, we're going to set up some scenes and nodes for our player, and that means it's time to explain what scenes and notes are in the good old game engine. You can sort of think of scenes as the complete objects in our game. So, for example, we might have a scene for a fountain or for our player. We might have a scene for you. I and all of those scenes would be made up of nodes. You can think of nodes as the ingredients that make up those scenes. So, for example, our players seen might have a collision shape and a sprite as its nodes. Each note serves a very specific purpose for the whole scene. Scenes also have this thing called a root node, which basically defines as specifically as possible the function of that scene. Understanding of this shit all fall into place as we started, create our players seen here. So over here on the right, we've got our seen tab, and this is where all of the nodes that are part of this scene will be displayed. So to add one and again, I'm looking for the most specific route node. That sort of defines the purpose of the scene. I will press this plus button. You can see I'm creating a new node. And this is the gigantic list of drop downs in the Gedo game engine, where all of these many, many nodes are. You'll gain familiarity with a lot of these nodes as you work with them and as you work in the good old game engine but from experience, I know that the most specific know that I'm looking for for this particular scene is the Key Matic body duty node. An interesting detail that comes from the organization of nodes in the Gedo game engine is that the Kinnah Matic body to D extends the code that's written for the physics body to D, which extends the code that's written for collision Object to D, which extends the code that's written for No. Two D, which extends the code that certain for canvas item, which extends the code that's written for the node, which is the most basic node in existence. So we've got our kingdom attic body duty as the most specific note that serves the purpose we're looking for and to display that a little bit more. I'll press create and you can see we've switched over to the to de Vieux port now because I've added a kingdom attic body to denote and just, for example, purposes. You don't have to do this as part of the tutorial, but to explain a little bit more about the function of a kid, a Matic body to denote, I'll go over to script and classes and type. Can a Matic body to D. Um unimpressed. Open. We can see that. Can a Matic bodies air special types of bodies that are meant to be user controlled? And we picked the Kinnah Matic body to deed to be the most specific thing. That sort of defines our player, which makes sense because it says the Kinnah Matic body to DE also has an A P I for moving objects. If we had just picked up a random No. Two D, we would have to reinvent the wheel and create our own moving slide methods or our own functions that helped body move. But we don't have to reinvent the wheel because the Canna Matic body to D comes with a lot of that functionality already and the code that we right well, then extend the canna Matic body too declasse, or add additional functionality to the kingdom attic body to D. So I'll go back over to R two D View Port and you can see we've got basically nothing over there so far, because while we've got a cinematic body to D, we don't have a Sprite or a collision object associated with it. And that's actually what this little caution is telling us. It says this note has no troll from shapes, so it can't interact with space. That's because we need a collision shape to t. That sort of defines the shape of Arcana Matic body to D. So I'm going to go ahead and actually name this player because this is the most specific note that we've determined. It will be a root note for a player scene, and I'll press the plus button to add another note. This time I'm looking for basic collision. Someone take collision and we can see we've got the collision shape to d right here. I'm working with two d. So this is correct. So now I've added a collision shape to denote toe our players scene, you can see that it is a child of the player or a cinematic body to denote, so it will define the collision shape of Arcana Matic body to D. However, we've still got a little caution symbol here. It says a shape must be provided for collision shape, duty to function. Please create a shape resource for it. Well, how do we create a sheep resource? Well, if we go right down beneath this panel to the inspector panel, the inspector panel will show us specific settings for whatever. No, we've currently got selected. So since I've got the collision shape to de selected up here, you can see that it asks us for a shape resource, which is currently no. And that's why we still have no shape appearing on the screen, and the player is still all cautioning and angry that it doesn't have any way of interacting with this face. How can it doesn't have a shape, so I'll go ahead and go to this drop down here and click new rectangle shape to D. I can go ahead and change the shape. If I want to buy dragging on these inner handlebars here so I'll go ahead, make it a little bit bigger, longer. That's our new player size there. And this shape resource that we've now created is a property of our collision shape to D, which is the shape that are player will use to interact with other objects in our game. So this is the basic node set up for our player seen. I could go ahead and out of Sprite as well. But for simplicity's sake, I'm just going to leave it as the basic cinematic body duty with the collision shape as a child. So to save, I'm going to press control or command s and you can see now it's giving us this path as rest. Colon forward slash forward slash This is basically the folder we created earlier called the Cranky Wizard. The rest colon slash slash folder basically means the root folder for everything that we're creating in our game. So player dot scene is fine and I will go ahead and just save it to this root directory. So I'll press save and you can now see that this finished scene we just created has appeared over in our assets because we've pressed save So now I've created our player scene , but we actually need a game scene that's going to contain our player scene. And the reason for this is that if we try to run our game in the top right corner here, press play, it's is no main scene has been defined. Would you like to select one? Well, no, because we don't actually have a game seen yet. The game scene will be our main seen. That then contains everything else that we want to run. If we were to select our player as our main seem, for example, when we start to run our game on Lee are player will appear and we'll have nothing else. And we don't wanna put like collision objects for collision items like our fountain, for example, in the player, because that would kind of defeat the purpose of having a scene specifically for the player . So we're gonna have a game seen. That then contains, for example, are collision objects like the fountain, and the player will do that and run our game for the first time in the next lesson. 5. Make the Game Scene: in this lesson, we're going to create a scene for our entire game that will serve to contain all of our other scenes, like our player seen to do this and create a new scene. I will press the plus button up here and then add the plus button, as we already did in the scene panel over here and now we're looking for a no. That is the most specific we can be for the entire game. Well, we know that our game is to D, but that's about it. We can't define our game as a k o Matic body to D because we don't want our game be a player. If we look at no tooty, which is the simplest to denote it says a two D game object, parent of all to the related notes. And it has a position, a rotation, a scale in a Z index. And you might think at first it because our game is to de that this is the most specific Weaken B. But we actually even don't need these things are Game doesn't need to have a position and rotation of scale or Z Index. What the most specific we can get for our game is actually just a plain old notices a base class for all seen objects. Every other note inherits from this note. So I'm going to pick this to beer main game node of the name it game. And here's where the magic of Gado starts to happen. I'll press control us to save Save it Is game not seen? And now I can have my player be a part of this new game scene that I've just created so I can put the scene that I've already made inside this game scene. And to do that, I make sure I've got game selected and I will right click my player and press instance. So now you can see our player just popped up inside our game and this is an instance of the scene. So if we were to make any changes to our player, those changes would update here. So now if we were to press play, you can see it says no main scene has ever been to find select one. Well, yes, now we can select one because we've created a game seen that will represent everything in our game. So Press Select Click game dot scene and now you can see we've got a little game running. We've got our players from the top left corner here. You might not actually be able to see the player. If you want to fix that, I'll just close this out really quick and debug. Make sure you've got visible collision shapes checked. If you don't have that check, you won't be able to see our nice little blue boxes in the game. Which makes sense. We don't really need our collision to be visible. But since we don't have sprites, it's nice for debugging purposes. So since we've got that checked, I'll go ahead and press play and my game starts up. It's nice. I've got my little player there, but I can't actually control it yet. I can't move it. And you might be thinking what we added. A can a Matic body to do you buy? Isn't it moving when we have our key? Bynes. Well, we haven't actually defined any script to actually make the player move. We just know that it can move. It has the potential to move, but we don't have any script telling it when it actually should. So I'm gonna go ahead and add some of that script right now. I'm gonna close this out. Open up the player seen by clicking this little scene icon next to the player under my game Root node. And now you can see we've opened up our player tab again. Our player seen I will click player and press this button toe. Add a script. The's default settings air. Fine. So press create. And that's it for this lesson. For a short introduction into scripting. And, kiddo, I will see you in the next one. 6. Start Coding with GDScript: Hey guys. So picking up right where we left off, We just added a new script file and it's attached to our Kinnah Matic bond duty, which we've named Player. So this is the code that starts out in the Kinnah Matic body duty when we create a new script for it. This first line here extends Kinnah Matic body to D means that we are extending the functionality that the kingdom attic body to T class already has. So all of the code that we right here will extend the functionality of the cinematic body duty, and we can also draw on the functions that already exist in the can. A Matic body too declasse in our own code. All of these great outfits that are tagged in the front are called comments. It's not actually code that is executed or run. Instead, its purpose is just to sort of explain what should happen in a certain section. What does happen in a certain section. It's basically just written things that help to explain the purpose of a piece of code. So this first comment here is telling us that class member variables go here and then it gives us some examples for the syntax of how able to find variables. If you are unfamiliar with the concept of variable, it's basically something that stores data that is expected to change throughout the code. That's a very simplified explanation of it, but it's a functional explanation for our purposes. So this next section defines a function called Underscore Ready that doesn't take any parameters, and those parameters would be stored in these parentheses. But they're not, and this commented out section here tells us that this function is called when the note is added to the scene for the first time, or this is our initialization coat initialization code is the code that will be run by the game engine. The first time I've seen is added to the game. So essentially the Gedo game engine will run this ready function when the scene is first added to the game. But we don't actually need anything to happen right when the player enters the game. This past que were tells kiddo that nothing needs to happen and this initialization function can stop here. The next and final block of code here in this Judy script file defines the function process Delta. So this is a function called underscore process that takes Delta or the time since the last frame as a perimeter. So because this function is called every single frame, this is where we'll store things that constantly need to be changing or updating. So this is the section will use to detect whether the player is pressing any of our key Bynes or determine whether they need to be moved in that particular frame. However, there is a little bit of a problem with this code as it is, and that is that this comment tells us this function is called every single frame, and we don't want that. If we had our players movement information updating every single frame, we would lose synchronization with Condo's physics engine. And if we had anything else in our game that would need to rely on God knows physics engine , this D synchronization could quickly become an issue. This doesn't really suit our needs. However, there is a function built into good Oh, that does. And that function is called the physics process. Good. I was Physics process runs out of fixed rate, so we don't have to worry about the speed of the computer being a factor in the player's movement. Speed to go ahead and update this part of the Judy script to be a physics process. Instead of just a process, I'll go ahead and add underscore physics. So this is now a physics process function instead of just a process function. And then I'm going to uncommon this line, which means the engine will no longer ignore the next. When we try to run this code, you can see that it's now giving us an error message because Goudeau is now checking to make sure that we've written actual G D script because we even commented this line. The reason for the error is that we need to actually put some logic in here so that Goudeau doesn't think we're just having an empty function to start doing that. I will write our first if statement and if statement is basically exactly what it sounds like it is. It checks whether a condition is true when that code is executed and if it is, it runs Samore code. So we'll use if statements to determine whether a certain key is being pressed and then execute code based on whether that key is being pressed to start. I'll go ahead and let all of our commented code press tab for an indention and type F space and put with a capital I, and this input is a singleton that basically handles all of our key presses in inputs. That's why it's called input and then I'll put Dot is underscore action underscore pressed , and this will basically ask is in action being pressed and, if so, execute the following code so you'll see that Goudeau is now giving us a drop down full of options that we can choose based on actions that we've written in our input map. In a previous lesson, they've got those quotes around them because they are strings. So I'll start with the 1st 1 to be moved, underscored up. You can see Ghetto is trying to auto feel for me, and then I'll close the quotes and closed parentheses and press colon press enter and then you can see that I've gotten indention here, you know, automatically puts that there. So this is all of the code that will be executed if the input action is currently being pressed for Move up. So that is our up arrow key and R W key. So I'll go ahead and put a comment here that says exactly what's happening when the player presses moved up and then is that the players target direction is up. I'll then right the past keyword to complete this little if statement. Basically, this is filler code. For now, I want to explain how movement vectors work. So how moving works in games before I come back and type in the actual logic. So I'll go ahead and do the exact same thing for moving down, moving left and moving right. And then we let my are nice pretty if statements and take a little break from coding that I can explain movement vectors. Okay, All right, So now I have set up skeletons. For all of my if statements, you'll see that God does not actually throwing us any errors, which means that this is valid code. It just doesn't really do anything. So in the next lesson, I'll explain a little bit more about how movement actually works in games and how we can tie this back into our code. I'll see you there 7. Implement Vector Math: in this lesson, I'll give you a quick crash course in vector math for video games and why we normalized Vectors of Accurate is basically just a line segment that's used to express forces. So vectors have length called their magnitude, which expresses the strength of the force and direction. Which, of course, is the direction that that forces being exerted in, in this case, regenerating vector with two dimensions X and Y that represents the velocity at which you should move. That's this movement vector here or our final velocity vector. To generate this, we first generate a separate factor to represent the direction that are. Player wants to move on Lee and then multiply all components of that vector by the speed to bring both parts of our vector together and generate our final movement vector. So I'm going to go ahead and jump into the Gedo game engine and create the very bills we need to represent. This will create a direction variable speed variable and a velocity variable to start here , and you know, I'll go ahead and delete this commented out section and tight V A R to define a new variable space and then I'll put speed. This is the name of the variable and then his face, equal space and then the number that I assigned to the speed will be the number of pixels. Every time physics has calculated that the player moves, I'll just put 300. It's kind of an arbitrary number, but we'll test that out later and see how it works for us all. Then go ahead and define another variable for direction. This very bold will represent the direction that the player wants to move, and so did to find a vector. In judo, we type a vector to parentheses, princey, and then we'll have 00 because we don't want the player to have any direction to begin with when they first start out the game. So this direction variable that we just created is what needs to change every time the player tries to move up down etcetera. So basically, when the player is pressing any of our keys designed to move the player upward, we'd update our direction. But which direction should we actually want the player to move in? Well, the check that will go to R two D view port and you can see that negative is up in good Oh , positive is down and then to the right is positive and the left is negative. So to reflect that in our script I will go ahead and right direction to assign our direction variable to a new value vector to zero comma, negative one. So just to quickly recap what we've done here, this function is called every single time. Physics is checked in the Goudeau game engine, so every single time physics is checked, if the player is currently pressing, a move up button will update their target direction 20 on the X axis and negative one on the Y axis. This should make the players target direction positive on the screen. I'll go ahead and update this for all of the other directions as well. All right, so now whenever the player presses any of our keys and move up, down, left or right there, direction should be updated accordingly. However, there is a little bit of a problem with this. It doesn't support diagonal movements because we are assigning the direction to our vector every time they press a certain key. So say the players trying to move left, and then they decide they want to move down as well in a left and down direction instead of moving diagonally. Because we are completely assigning it to a new vector, they would just replace their old movement and moved down instead of left to adjust. For this, we can add a plus sign here and say that we're now adding every single time they press the new button. So left and right, for example, will still cancel each other out, because when you add negative 1 to 1, it'll be zero. But if we were to add the vector to negative one and zero to the Vector 20 and one for left and down, they would now move in this direction. However, this introduces another problem, so I'll jump into my power point slides to demonstrate that for you really quickly. So say the player is just trying to move upward. We really don't need this Pythagorean theorem here, but it is helpful to visualize because the vector represents the up direction from the origin to the 0.1 Its magnitude is just one. The same is true if the player is just trying to move right again because this factory represents the right direction from the origin to the 0.10 Its magnitude is also one this holds up with the player wants to have exclusively left her down as well as it just discussed. However, we do run into trouble when the player wants to move, for example, both writing up a the same time in a diagonal direction because the code we just wrote adds vectors together to create combined monstrosities like this one. We now have vectors with a start point of the origin an endpoint, for example, at the 10.0.11 This creates, according to the Pythagorean theorem, a vector that now has the magnitude of the square root of two, which is larger than one. This means that if we try to use that as our direction vector to eventually be multiplied by our speed, the player will move faster when they're pressing up and write, or when they're pressing down and left. Then, if they were just pressing one of those directions to prevent such a catastrophe, we normalize the vector before multiplying it by our speed. The normalization process allows us to both preserve the direction of a vector by maintaining its extra high ratio and forcing the magnitude of that vector to you. Call one. So through normalization, we can prevent any variances and speed by faulty direction vectors. It's, thankfully, pretty easy to normalize direction vectors in good oh so put enter delete. Enter. I'll go ahead and leave this extra invention that divided here, and then I'll type direction to assign our direction. Vector to a new value equals direction. Dot normalized with two parentheses at the end doesn't take any parameters. This is all it takes to normalize our direction. Vector. After this process is completed, we can now introduce our velocity vector. So go back up to the section where variables are introduce a new variable called Velocity, which is another vector to We don't want the player to have any velocity at the beginning of the game. So we'll just set this 20 on both the X and Y values. So now that we've already updated the direction vector here, we can go ahead and press entered like that extra induction there and then a sign. Our new velocity variable to direction, times, speed. And now we've generated are nice final velocity vector that the player should use to move. However, you might notice that there is no condition for if the player isn't pressing anything, so to resolve that, I'm just going to go beneath the physics process here and set direction equal to zero are a factor, too. Was your on both the exploit and this basically prevents a very uncomfortable stickies effect? So basically, what would happen here if we didn't do this would be that the direction variable would just constantly be adjusting, never really reset back to zero. So if the player let up on a button that they were just pressing, they would actually continue to move in that direction. Basically, what this line here does is reset that to prevent that from happening. So now we've got our complete controller going here. We just have to tell Goudeau to move the player in that direction. So I'll say, move and slide with underscores there, and this function does take parameters. It takes our velocity as a perimeter. So, no, If I go up here and press the play button, you can see I've got my player up there in the top left corner and they move when I use the arrow keys in the correct directions and they move when I used the W A s D keys in the correct directions as well, which is super satisfying. So that's one last variable here that I wanted to introduce. I'm just gonna add it right here. It's called the Floor Normal, and I just said it to a vector to for our purposes with 00 and basically the floor normal variable is the line that is perpendicular to the floor in our game, which is a top down, RPG style game that would sort of be like sticking straight out at us into the into the real world, which we don't really need. The Florida more variable for our purposes. Here it's included in a moving side function by default. If I were to go here at a comma in a space, you would see that the vector to floor normal is by default 00 However, if I were trying to create, say, a platformer, the floor in the game would be parallel to the bottom of the screen. So a just for that I would adjust this to say, like negative one or some things. So now the floor normal would be assigned to a vector that is going straight up, which would mean that Goudeau would recognize the floor in our game as being parallel with the bottom of the screen, which is what you would want in a platformer. It's not really necessary that I include this for editorial, but I figure some of you are probably going to not want to create an RPG or top down style of game. This is just a little pointer in that direction, but for my purposes here, I'm just gonna go ahead, delete that and believe this extra bit here and the next lesson in a lot. A few more peripherals, like a camera and some other things that we can collide with just for funds that I can show you a little bit more of a demo of how this will work. I'll see you there 8. Add a Camera and Some Collision Objects: All right, So in our last lesson, we actually finished up our character controller. I said in this one I would pick up right where we left off and just add a couple of peripherals. Adding a Cameron Goudeau is actually really easy. I'm just gonna make sure I've got my player selected in my player scene and then press the plus and type camera because you have got the two D camera note here, and it automatically added to our scene. We just did check current here in the Inspector. Make sure is set as current. So if I go ahead and test it by pressing play in the top right corner, I've got my player now moving around. It looks like I can't move outside of this little rectangle that I'm currently outlining here but actually can and I actually am. It's just that the camera doesn't move while I'm moving inside this truck tangle, and it is moving when I'm out here. So the camera is currently moving up into the right. You just can't see it to prove that and prove that I'm not just going completely crazy. I'm going to add a couple of other collision boxes here just so that you can see that removing. To do that, I'll go ahead and add a new scene in the tab up here, Press Plus, and in my new scene, I will add a plus here, and I'm looking for a static body to denote. This is static body for duty physics. It won't respect physics. It'll be static. It'll stay constant. And that's just what you want for this purpose. We've got the same issue, though, that we did when we first started creating our player, which is that we need a collision shape to D. So I'll go ahead and add another note here for a collision shape, duty, press, create and then set our new shape for a little thing. Let's say that this shape is a circle. I'll go ahead and make a little bit bigger. I'll name this just collision box you go. And now I'll go ahead and save the scene. So control or command s I'll save Collision box dot Seen just to my route path year press save. And now I will go back to my game scene and instance So right, click and instance this a few times, but it's is no parent. Instance the scenes at starting to make sure I've got my game selected here. Try that again. Now you conceive. Instance, are collision box in our game seen alongside our player? So now I can just sort of drag this around. All right, click and instance. Make sure I've got game selected up here. Right click Instance Again. Click game again, right click instance again, and you can see Goudeau is just automatically adding the two in the three to make sure that no notes trade the same names. I'll drive this over here a lot. Maybe over here a little bit, and you can increase the size of this one. However you'd like so truck like that. And then I'll press play to test in the top right corner again. And now you can see that I am, in fact, moving when I go outside this little box, and it's a nice, beautiful camera that transitions nicely, and I cant collide with these things. I try to go over here, you can see it's not letting me into their because it is a functional collision. So, yeah, this is a functional character. Control that we've created in the good old game engine. I'll see you guys in our final video lesson for some final thoughts. 9. Final Thoughts: Hey, guys, Thank you so much for taking my first class here on skills here. I strongly encourage you to tweak our character controller, make it your own and tell me about the changes you made in our cost project. I'm already planning some other classes related to game development and just gaming in general. So if you're interested in any of that piece, do you follow me here in the platform? If this class helped you in any way, I would really appreciate a positive rating as well. Please don't hesitate to let me know if you need any further guidance. I'd be eager to help you out. To keep learning for now and continue building a game in the video game engine and recommend taking a deep dive into scenes and notes. I'll put some links in the class description for you. Thanks again. So much for being here and taking the class. I really hope it was helpful. Helps you against him.