How To Use Enhanced Input System With UE5 Using The VR Template.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey everyone so over in the Discord there's been some confusion on the enhanced input system included with 5.1 and essentially what happened with the old system that epic used to include um basic rundown is the old system is now deprecated so it's being removed so you don't add inputs from Project settings anymore and instead you have a whole bunch of files that you need to set up and this is what's caused the confusion so what we're going to do is we're going to take a look at how enhanced input system works uh how you can use it or kind of understand it and then towards the end I'm going to wrap up and I'll show you how I'm utilizing the enhanced input system to allow for for controller switching and different input modes or movement methods that I'm using in the VR template so the first thing I'm going to do is boot up the VR virtual reality template by Epic and the reason I'm using the VR template is because I've got my Vive setup and it's got some inputs on here that we can use and then we can go through that and show you how to set up some button presses so once that loads we will Jump Right In so now that we're in and it's all loaded up we can go to our VR template and then we have an inputs folder and this is pretty much where everything lives for our inputs so if we start off in actions we can go through these um the basics of actions are there they're all basically are headers these are what we see inside of our blueprints so we would call input IA underscore grab right and we can see that if we open up our blueprints so it'll be a pawn and we bring that over to the other screen once it loads there we go we can see here we've got IE grab left and grab right so these are what we call in here so let's say you wanted something that does uh it's not in this so we can do a jump so we would right click and we could go to input we would create an input action all right this input action would be IA underscore jump okay and there and then we can open it up uh what we want in here is this is the options of what our input is going to contain like what is our input gonna do and because it's a jump It's essentially a boot so it means it's an on off value you could switch to float so let's say you've got a trigger and when you pull it we can track between zero and one how far through the pull it is you could do stuff like that so axis 1D would be triggers that kind of thing and we want to keep consuming but as it is and we don't really need to do anything for triggers or modifiers for now that's fine and what we could do is add an action description in this case it could be called jump now what we would do here is you can see that we can't add any actual controller inputs so it won't communicate so in this case we would go back to our folders we would go back to inputs and this is where we would start looking at our input mapping contexts so best way to think about input mapping context is essentially groups of inputs for what you want something to do so in our main actually default will be a good one so in default this is our default player controllers when we start our VR phone is going to take our default inputs and it's going to use those that we can control so if we open it up and we drop down mappings you can see everything that we need for our player to do on start is available here so I a move turn grab left grab right menu toggle a menu toggle right this is essentially everything that our player is going to do when our game begins and see that here so if we scroll up to the top we can see that in our vehicle we have our begin play and then after we get our set tracking origin and our execute console command We Now call our ad mapping contexts so this is probably where things get a little bit more confusing because you need to apply assign inputs but we can see here that it's as simple as get player controller enhanced input local player subsystem and then we add mum in context so what we're doing here is we're saying on beginplay we're going to give our player these controls of IMC default which is the ones that we read in this input and what that does is it allows us to enable a disable certain inputs in projects and unlike previously we can actually control C and Ctrl V and use different inputs at the same time so you can see how we can you can kind of utilize this to a lot be a lot more powerful and what we do here as well is in our IMC default we also add our hands so like I was saying that basically groups we have our VR Pawn that controls everything in here and then we also have our hands which we could then enable a disable and we could see those in our IMC hands we then have a menu the weapon left and a weapon right and these essentially ads or these are basically what we want to enable and disable so we kind of want the control over them so if we open up default again you can see that we can open these up and this is now where we add our inputs so our controller inputs so let's say we want to add jump we could add a mapping here in our default because once our player starts it's going to be by default it's going to be enabled so we're going to search for our jump in the drop down search jump and now we can go through and we can add our inputs so I have my five added to the project Let's Do Right a if it's going to let me and I do not have my Vive it is a valve index so I'm in the wrong place so write a pressed we can call that and because we've added it to our default it means inside of our VR Pawn we're already adding it and to be honest we could add it even if we didn't have the default which would allow us to enable it later on so we can right click and then we search input action underscore jump and you can see at the top here we've got inproduction jump we can call this and now this is where it can get a little bit more complex as well and what this does is each input action has different variables attached to it so triggered is fired when we pull the trigger or we press the button and hold it down so it's it's continuous started will fire once when we first press the button or at any stage that the input is being activated ongoing is kind of is it still being pressed or processed canceled has it as have we used something else to cancel the input and then complete it as as it is Have You released and then gone from there so in this case you would do startled and then you would activate jump we don't have anything to do that's a little different string and what you see jump started now if we hop into the headset and we boot up it's gonna crash be right back so if we do that again we can hit compile and we can jump in we can then press our a button and we can see in the top left there right there that we get our input when we press our a button so that's adding inputs to an existing um mapping context so input mapping context we're adding inputs directly to one of these already but what happens if we want to add a new one let's say we have um a new movement method called Smooth logo motion which I will be doing a video on so make sure you keep an eye out for that what we want to do is we want to right click and input action input mapping context and like I said before this is basically a group to contain all the inputs that you need for an action to happen so IMC underscore um smooth locomotion and then we can hit enter so if we open this up you see that we can add our mapping context we can only add one at a time which is something to keep out but we need something that allows us to use our player and our character as normal so what we could do is we can go through grab left grab right and then we have our hands which are controlled by our other group we've got jump we've got inproduction turn and then we would want something for move forward and move back so in this case what we do is we can have a new input action so input action underscore move forward and in this we're going to make this a axis 1D because it's only moving forwards it's going positive to a negative so we'll have float and we'll say move forward it's worth noting that this action description cannot be repeated I had a set I had a problem where my description inside of my input mapping contexts were duplicated and it was causing a crash so make sure these are separate to what other inputs are so action description is its own thing and input mapping context description is it's a unique thing as well so we added we created input action for forward we can duplicate that and I would say move sideways over that way so we got both of those and now in our smooth Locomotion we can add our move forward and our move back that move back let's move sideways if I spell it right move sideways so here is where you can go through and you can set up your inputs which we've already shown if I bring over a project that I've been working on so if you've seen the VR template I've been developing I'm going to show you the project on there so I'll show you the inputs for the smooth Locomotion system I've got set up so we'll quickly take a look at this and then we'll move back if I can drag it over and you can see here that I've got a whole bunch of other groups and inputs available to the user so smooth Locomotion if I open this up you'll see the type of inputs that I'm including so we've got move forward horizontal grab left grab right Sprint jump snap turn uh toggle menu and toggle menu right and if we open these up you can see I've gone through and added all those inputs so this is essentially where it gets added and that allows you to interact with them and add them to your project so rather than going through and adding everything I'm just again going to add our jump and then we'll call this uh we'll use five index uh right ear pressed and we'll keep that as it is because what I want to do is I want to show you that if we change our input mapping context inside of our VR Pawn so we're not using IMC anymore for a default we're now using smooth locomotion when we hit compile and we press play and we jump into the scene when we press the button nothing happens even though we have that jump attached to our print string still so the question is why is it that we've assigned a smooth logo motion but this input action isn't firing I think this is where the most confusing part comes in is inside of our template if you've had a look in the action folder or the input folder you'll see we have a player mappable input config and what this does is essentially tells the editor or unreal in your game which one of these input mapping contexts should be included with it so if we open this up we can see here that we have our context and we have default our menu weapon left weapon right and hands these are all being used in the VR template right now so you would need to change it and that's why because adding the new Jump function or jump input to our default worked because it exists here so what we do is we could add our smooth local motion to this now so we do drop down smooth Locomotion that's now included and just so you know where this exists if you go to Project settings it's actually easy to search all settings and then search enhanced you'll see that we've got some options here for it so we have default editor in class enhanced player input default player input class enhanced player input and then enhanced input component they'll be set to default you don't need to worry about those but you'll see in plugins open XR input we have our player mapping input for VR template and that's the one that we just added our groupings to essentially so you need to make sure it is in your project settings and you can find this one specifically down in open XR input and then you could make sure you've added it here so I like to switch it out if you needed to but in most cases you can just add all of your contexts and input mapping contexts into this file so in here we've got numbers as well and these are kind of like priorities so what you can do is you can have an imp you can have multiple input mapping contexts like use the same input so you saw in default we have our jump and then in smooth Locomotion we also have jump inputs if we had these enabled at the same time inside of our VR phone so we had I've mapping contexts and that was duplicated and set up so we're using both let's say move and we set that back to default then we need a priority so one of these would have to take priority over the ellip to stop the inputs uh misfiring so that's what that will do there I believe I'm pretty sure it is So Below the number the higher the priority and then as you go through you would get that input there but in our case you would typically remove the default and probably switch it with smooth local motion or add your smooth stuff to the default it's up to you how you go but what that does now is now that we've added our jump to that file so to our player mapping player mappable input config we can then press play and then if we press the A Button now we can see that now it jumps so a big one down you have actions which are the name of all the things that you want your buttons to do so it's a jump grab uh scroll slide aim reload um oh God open menu interact with the UI that kind of thing anything that your player is going to do just have an action for it and that action is going to be either a bull or a float so you can see here grab left because it uses a0 to 1. it actually uses axis 1D but if it's a button it's going to be a grab so once you've got your input action set up you can then go to inputs you can either add them to an existing input mapping context or you can create a new one by right clicking and going to input and then input mapping context so once you've done that you can go inside of that mapping context and add in all of your mappings so yeah you'd add your action and then your inputs for that action and then make sure they're added to the actual player mappable input config so you can access them one thing I didn't go over is about removing enhanced inputs so we have our smooth Locomotion set here but let's say we wanted to change that to a different movement type we could actually tell unreal to remove this and replace it with the new one and what that'll do is it'll immediately remap all of your controls to match whatever controls you have in here so it's a inside of the gun which already exists we can open up the pistol and you can see here we have our inputs so when our grab component is grabbed so on component grab we enable input for the player so we say okay this blueprint can get our inputs and from here we choose if we're using the left or right hand and we say get weapon left or web and right which we then add to our mapping context so if we use if we grab with our left hand it will use the left input mapping context and it will add it to our gun so we can then call those input actions in this case it's shoot left and we do a double check to make sure that we're holding the gun with our left hand and then we go through and fire it once we release the product the object so on drop we disable the player input and then we remove the mapping context back out so as you remember you've got priority options so you don't want your mapping context to stay attached to an object that you're interacting with if it's going to override something else but because this you can add and remove them you can switch this around so that's the basic rundown of input mapping context and enhanced input system so what I'm going to do is I'm going to show you by closing this project and I'll open up the VR project I've been working on so if you're part of patreon you'll have already seen this and I'm going to show you how I'm using it to allow switching for real-time movement options so we've already taken a look at in our input system how to use it and in the VR template so if I scroll back we have a menu and you see here I've got options to choose what kind of movement method we want to use so I've got a flying option I got a smooth Locomotion smooth Locomotion and teleport shift movement and then teleport which is kind of the default but it was renamed so if we open up our flying you'll see here I've got an input action for flying forward flying horizontal flying up down snap turn right grab left and grab right and this is kind of the same thing through all of these groups so when we're using smooth Locomotion we only want to be able to use these input actions whereas I've got smooth local motion with teleport which has the teleport input actions onto as well so if I bring these side by side we can see how we've got them lined up here and the only difference is literally this added the teleport so what we can do is or at least how I'm doing it inside of our blueprints I have a VR character and ignore all this there's a work in progress we've got our movement graph and at the top here we have options to re re-jig our mapping context essentially so what I've done is if you've seen any little videos I have a data asset which allows me to choose what movement type I'm using and then I have a actual array as well inside of iPlayer so this array contains all of my mapping contexts of what the player has available to them so in this case there's five different movement options and we go through that array and we check to see if it's similar to one that we've already got so movement type if it's equal to our movement type we can say true then we can add that mapping context to our player if it's not then we remove it so simply refiring this section allows me to change through each one of these inputs to fire in real time so if we jump into the project so now that we're in what we can do is we can use our smooth locomotion option and then we could say movements let's say switch to teleport so now I can't actually move but my rotations change to my left hand and now I can teleport around um let's say I change to shift movement we can then use that one and we're basically remapping all the controls so my my control the snap turn is on the left controller but have I got a smooth logo motion it's now on the right and then I can move around and do teleport and have that so that's pretty much the benefit of this is being able to add and remove inputs and mappings as you need them but it allows you for a more Dynamic control over your project and where to use them so I'm trying to think if we've got anything else in here that could be useful to show and objects not really we've got our table Maple input config and you can see that I've added those in here as well so the project knows what to use and then input actions I've got them all stored in this folder so that's pretty much it it's a little bit in depth hopefully but kind of repetitive as well I'm hoping that it just gets across from what it is you need to do and that it's actually pretty easy um the best thing you can do is if you're stuck is to just check out some of the blueprints that are already in the VR template such as the weapon which shows you how to add and remove them and then just play around with the player controller other VR character to see how that goes and how the inputs are working on there add remove play around the kind of thing so yeah before I end it I just want to say a big thank you to all patreons who have made this possible especially this plugin that I've been working on um so if you want access to this and you want to try it around and fly around that kind of thing then definitely check it out um if you need any help with enhanced inputs and you're not too sure where to go got a link in the description for our Discord server which we're almost at 2 000 people so if you need any help head on over there and we'll be able to give you a hand but yeah all right until next time stay safe and I'll see you then bye
Info
Channel: GDXR
Views: 14,393
Rating: undefined out of 5
Keywords: Gamedev, Indie, Indie Gamedev, Indie game Devlog, Game Devlog, Game, Dev, XR, GameDevXR, Blueprints, Coding, Unreal, Engine, VirtualReality, VR, ExtendedReality, tutorial, how to, how, To, develop games, making a game, Dev Log, beginer, Unreal Engine 4, archviz, architecture tutorial, beginner tutorial, basics, blueprint tutorial, blender, beginner tutorial series, coding, devlog, Jonathan, Bardwell, code, unreal engine 5, enhanced, input, system, for, vr, Virtual, reality, UEVR, bardwell, log, development
Id: GLEPEKx6Km0
Channel Id: undefined
Length: 25min 51sec (1551 seconds)
Published: Tue Jan 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.