Hello and welcome to another episode in the Godot basics tutorial series. In this episode we will be taking a look at input maps input maps. In my opinion is the easiest way of handling and editing player inputs in order to use input maps. We have to use the Godot application. In Godot when you go to project settings you'll see different tabs. One of them is called input maps. Inside this tab we have the ability to map basically a string value.
In this case UI focus previous and map it to a specific key or key combination set. In this case UI focus previous is mapped to the key combination shift and TAB. As you can see here we have other mappings as well such as UI left being mapped to the left arrow key and the DB left pad on a control device. And over here we have the string UI right mapped to the right arrow key which is also mapped to the controllers the right d pad.
We also have other customization features as well. For example we can customize the dead zone that our input has on top of that we have the ability to add more keys onto our string map. We can also edit our current key combinations or we can delete our key combinations to use the input map we can use the input Singleton. In this case we use the input Singleton followed by the dot notation followed by is action pressed and in our parentheses we need to pass any string value which is the name that we gave to our input map.
In this case we're going to call you I underscore left. And basically when our user presses either the left arrow key or the left d pad we are going to run this line of code or rather this line of code is going to pass back either a true or false value. One thing to note is that because our method starts with the is keyword we do know that p value we will get back is a bullion value on top of that. We also have the input map Singleton the input map Singleton manages our input event actions input event actions inherits from input events.
So basically we're handling input events this Singleton gives us the ability to add edit and delete our input mapping when our game is running I won't be going over it in the example however just note that the input maps Singleton allows us to edit what we added in our project settings let's go ahead and take a look at an example I've opened up project settings and we are inside the input map tab as you can see here we have UI left and UI right you I left has the left key and you are right it has the right arrow key something I did not mention is that we can also add our own custom mappings as well to do that we go over here where you see the word action and on the action we can go ahead and give a new name in this case we can say new move and you just come over here press the ad button and towards the bottom you're gonna see our new move and by D4 we're given the dead zone zero point five however we have no mapping and so in order to give it a map just press the plus sign which will add a new event in this case we're given options key Joy button Joy access and mouse button we're gonna go ahead and press key it's gonna ask us to pick a key we can pick one or several keys remember that order matters in this case shift and Z we're gonna go ahead and press OK and now we have a new input action which we call new move and it is mapped to the key combinations shift and z we can also go ahead and edit by pressing the pencil button in order to change our values and we can go ahead and press the trash can which will remove the input from our new move and that's basically it now from the previous homework assignment we went ahead and added our own key values through raw code we're gonna go ahead and change that and use the string values from our input map tabs in this case you I left you I write UI up and you down over here and our physics process you can see we have our inputs Singleton with the is key press and we're getting our raw integer value which is our scan code in this case key d a w s and in order to use the input mappings we have to use the is action press method and so all you really have to do is just go ahead and change that value. And
And now when we run the game in this case moving to the right I'm using the right arrow key press and that's basically it you have the ability to use either a scan code using the is he pressed a method or you have the ability to use input mappings through the is action pressed method. Well that's all I have for you in this episode. I'm gonna go ahead and upload to get hub the new edited version of last episode homework. Using the is action pressed method which uses our key input bindings from Project settings.
Please go ahead and check that out. Thank you so much for joining me. Thank you for clicking the Like button. Thank you for clicking the Subscribe button. I look forward to seeing you in the next episode. Have an amazing day.