A Simple Guide to Setting Up Unreal Engine Enhanced Inputs for Virtual Reality

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
when it comes to developing games there is one thing that I consider to be way more important than most things When developing a game and that is inputs and the reason being is that inputs are required for everything in a game to function it can go from Simply being able to walk around an environment and being able to look around it all the way up to being able to grab objects open doors and so on so forth there's a lot of very important things that inputs are necessary for for the overall interaction and the experience by the player so in this tutorial I want to break down how the very basic enhanced inputs are set up and how you can easily Implement them into your own character or other assets that you may have in your project but before we jump into that if you enjoyed this video and want to help support VR play around consider becoming a member down below or just hitting that like And subscribe button all these are great options to help VR playground so that way we can help grow and create even more tutorials just like this one and with that let's Jump Right In the video now before we get started with the actual guide portion of this I wanted to show you real quick what the Legacy inputs look like in case you are unfamiliar with or you're curious as to what the difference is between the enhanced and the Legacy input system so if we go into the project settings we can go right into input and in here we have action mappings and axis mappings it's really quite simple and the only reason that we're starting to transition into using enhanced is simply because the action and access mappings are going to start being phased out slowly over time so we can come in here and essentially this is how it would usually work you would come in here you would give each action mapping a name and you would tell Unreal Engine exactly what button is bound to this action mapping it's really simple there's really not a lot to it it was very very basic Now by comparison the enhanced is a little bit different we don't need the project settings first off what we want to do is we want to open up our content browser and I already have a folder here called inputs I'm going to right click and under input I want to open up an input action and we want to give this a name so I'm going to call this left trigger okay this is going to be our first input action and again this is very similar to what you would experience in the project settings now if you're just using like a simple button like this one left trigger there's really not a lot that needs to be done all you need to do is make sure that this is saved and that's really it however if we want to do something a little bit more advanced for example we could come right in here let's create another new input action let's call this one left thumbstick okay so left thumbstick there we go and in here you can see we don't have a whole lot of different options or anything to work with going from bottom to top we have modifiers and triggers and I'm not going to go into this for this tutorial if you would like to see a future tutorial leave a comment down below letting me know you guys would like to see a tutorial on modifiers and triggers and if we come right up here we have value type now since we're using a thumbstick we don't want this to be a bull we want this to either be a flow of an axis 1D or we want this to be an axis 2D which is a vector 2D I'm going to set this to a vector 2D and I'll also create one that's an access 1D here in a second and above this we also have a reserve all mappings trigger and pause and consume input now you shouldn't really need to mess around with these three all that often um you can Mouse over these if you'd like to see a little bit more information on all these but you really shouldn't need to modify these at all you should only really ever need to modify the value type now the reason you really only need to modify the value type is actually pretty simple the value type will help you as the developer determine what type of value you get when you're using any sort of input so for example here on the thumbstick the reason we're using an access 2D is if we look at a thumbstick I have a couple here so we have a Gamepad and a motion control that we'll be setting up if we look at the thumbstick it actually is Left Right and up and down that's the very definition of an axis 2D having two x axes on it now alternatively we could split this into two different axes we could have a an axis 1D and have left and right as one and then up and down is one which I'll be showing you how to do that as well once we've made these modifications to the input action all we have to do is hit save and close down this input action and I'm going to go and create one more I'm going to call this one input input action and we'll call this right thumbstick X and we're going to use this as our axis 1D value I'm not going to bother with the axis 3D there's really not a lot of needs for an access 3D so I'm not going to bother with that for this tutorial now that we have these input actions set up now we need to actually Define what buttons are bound to which of these input actions and this is again pretty simple to do and it's very similar to what we did in the project settings all we do is we come up here input and then we want an input mapping contact and I'm just going to call this mapping context there we go we can open this up and just like I said this is very similar to what we had in the project settings all we do is we hit add action mapping then we need to choose one of the action mappings that we set up so I'm going to start out with the left trigger since this was the first one we set up I'm just going to call this left trigger there we go and we'll find our input action right there and then we Define which inputs are bound to this input action so I'm going to use two here I'm going to use my valve index that I have here and we can call this valve index left trigger and I'm also going to hit this plus button to add a second input and I want to go into Gamepad and I have here just a simple Gamepad and I'm going to use let's see here gamepad left I'm not seeing it here there it is Gamepad left trigger uh took me a second to find there and all this means is that if I hit either my valve index Trigger or if I hit my game pads left trigger that's going to call this input action I'll show you how we can use those in one sec let's go and set up the other two input actions so next one let's do the left thumbstick there we go and in here again I'm going to do two inputs let's start out with the valve index again we'll do valve index left thumbstick and since this is a 2d axis our left thumb stick you'll recall that we set this as an axis 2D we can come down here and we see that we have an option for a 2d access for the valve index left thumbstick and that's what we want to have there we can do the same thing for our Gamepad I'm going to type it in this time do Gamepad left thumbstick 2D axis just like that now last one is going to be this right thumbstick X so I'm going to put in one more and we'll do right thumb stick X again we'll do two inputs and valve index is going to go first the order doesn't really matter by the way if the only reason I'm doing it in this order I I like to keep it consistent between all of my different input actions so that way they're all they all go from the same system down so we can do valve Index right and then we want the thumbstick x-axis for this one and you may recall this one when we set up the Axis 2D if we do Gamepad write thumbstick x-axis so this means that's only going to record our x-axis on this one that's going to be our left and our right value so we can go and hit save and now we can close down this mapping context there's really no more need for that now we need to actually use these inputs so I'm going to go ahead and jump into the VR Pawn that I have here so let's go and open this up and I've removed all of the initial inputs we'll be doing everything right from scratch now if we go ahead and jump in here and we do our left trigger you'll see that we do get this enhanced action event and we can drop this in you can see that we can start setting everything up and we have different options for triggered started ongoing cancel completed all this kind of stuff let's go and set real quick just a simple print string here left trigger pressed there we go now if we try launching this just as it is right now so you can see right now all we're doing is printing out a string then let me go and start off with the GamePad I can go and hit left trigger and you can see that nothing gets printed again if I go and grab my valve index and hit the left trigger nothing gets printed so what we need to do is go and hit Escape out of here and what we need to do is on begin play or at some point before we start running any of these inputs we need to come over here and I'm going to get a player controller then I want to get the enhanced input local player subsystem then using this we want to add a mapping mapping context just like so okay so the mapping context needs to be the mapping context we created so is this one right here I'm just going to drag this and drop that right in there and we don't need to worry about priority or options again you probably don't need to worry about this in most scenarios so I'm just going to leave it alone but if you want to add like options these are the options that you can possibly modify so we can go and hit compile and Save and now if I go and hit play you can see if I grab my Gamepad the controller now works the the controller will now print out that input that we have however if I take my index and hit trigger you can see that there's still nothing that happens and the reason for this is actually because of it is actually a VR issue specifically now the reason that this is an issue only in VR is actually pretty simple so if we go into our project settings and we scroll all the way down to the bottom on left hand side we'll find this option for open XR input and you'll see that we have this option right here for a mappable input config for XR and we need to set this as you can see this is set to the default the PMI underscore VR template but this is no longer relevant to us because we're no longer using those mapping contexts so what we want to do open up our content browser and I'm just going to add it right here in inputs I want to go into input and add a player mappable input config and I'm just going to call this open XR config and I'm also copying this name as well and the reason is we need to give it a config name so I'm just going to control V in there I don't believe you need a config display name but I'm going to go and drop one in just in case and then we need to go under context and we need to add in our mapping context here to context now once we're all done with that we can go and close down our openxr config and in the project settings we just need to drop in that openxr config and so now if we go ahead and launch the game you can see again Gamepad will still work and if I grab my valve index trigger is now working because now we've added in that mapping context into the openxr input it's very very simple to do now let's go over these input actions that we created so let's go ahead and draw up in the other ones too so let's grab our left thumbstick and if we come right up here you can see again we have two options here for left thumbstick I don't know if I point this out with the left trigger but if we look at this we have two options for the left thumbstick we have this one which will just give us the value from our left thumb stick and then we have the other option come on left thumb stick and then we have the other option that's basically just going to create exactly what we have here the same in enhanced input action then let me also go and grab our right thumbstick X as well okay so right here you may already notice that there is one thing that's not similar between all three of these and that is the action value and the reason for that is if you'll recall we gave our left trigger a bull value or rather we left it as a bull value our left thumbstick was turned into a vector 2D and our right thumbstick X was turned into just a single float now right above these action values you also see we have five different execution notes and that goes for all of these different enhanced input actions now these work pretty similarly depending regardless of which uh input you're feeding through so I'll run through these real quick so I'm going to go out of these just a little bit out of order just because this going through them in this order doesn't fully make sense so I'm going to go at these a little bit out of order okay so starting out with this started for buttons this occurs right as soon as the button is first pressed now for our thumbstick value since these are both axis values started occurs as soon as our thumbstick is no longer equal to zero zero basically all this means is that for thumbsticks this occurs as soon as we start pushing our thumbstick in any direction unless you have stick drift then this may accidentally occur after that we also have completed completed for buttons occurs as soon as our button is released okay so this is basically right after this is kind of considered the end of our input on our thumbsticks where we have the axis values completed occurs as soon as our thumbstick is returned back to zero zero basically it's no longer being pushed in any direction again unless you have any sort of stick drift then this may continue going on for some time now finally we have triggered and triggered occurs the entire time between started and completed so for buttons this has occurred triggered occurs so long as the button is being held down and for the thumbsticks this occurs so long as our thumbstick is being pushed in any direction so we can use this to continuously get a value from our thumbstick for example or we can use this to figure out if a player is still holding down a button now ongoing and canceled as far as I found does not occur naturally by any sort of thing that the player can do so it's not really something that I've that really occurs a whole lot so they're ongoing canceled really isn't something that needs to be worried about at all now before we finish this off I also wanted to show you real quick how the action values worked on our thumbstick because this was something that I think is really interesting and is something that is just really fascinating to me personally so if we come here into our thumbs did let's start out with our Vector 2D left thumbstick now I'm going to on print string I'm going to run this during trigger okay so if we grab our action our action value this is a vector 2D which means that has an X and A Y value we can compound save this and run play and I'm just going to grab the GamePad here for a second you can see that as I move around the GamePad we start getting different values so for example as I move it up you can see we start getting close to that y1 and X 0. I'm having a there we go I I was having a little difficulty getting exactly as I move it left we get negative 1 on x and roughly 0 on the Y again I'm having a little trouble getting the exact value there if we go down then we get our negative 1 on Y and zero on X and right becomes our X1 and our y 0. again I'm having a little trouble there we go got the exact value and then as soon as I release you'll see that of course we start getting that print string now alternatively if we were to bring this down to our right thumbstick where we only have the single axis value so I'm going to run this on triggered go action value straight into the string then we can go ahead and hit play on this one and this one's tied to the right thumbstick so if I press right on the right thumbstick you see we start getting close to one and this time we're only getting one value because this is just a flow now if I move it up you'll see that I'm still getting some kind of value um I'm trying to see if I can get exactly zero but I don't think I'm gonna get it um you'll see that we'll still get a value that's going to be close to zero same if I go straight down and then all the way to the left we're going to get negative one so this is just going to return a single value on a single axis and then we also have the option to do a y value which would mean that up is going to be one down is going to be negative one and anything else in the middle is going to be between either negative one and zero or positive one zero depending on what what the thumbstick is more leaning to and that's just a simple rundown of how these enhanced input actions work and that's it enhanced input actions are actually pretty simple to use and very easy to work with and what's really cool about this form of input action is it allows for us to either enable or disable certain input actions or enable them only under certain conditions so for example we could add a mapping context that only enables when a player picks up for example a gun and this would allow for us to only fire that gun if it was picked up it's a really interesting and honestly makes things a lot easier overall I hope you enjoyed this video if you did be sure to like And subscribe button down below and I also want to give a huge shout out to my patreon supporters and with that I'll see you in the next reality
Info
Channel: VR Playground
Views: 6,317
Rating: undefined out of 5
Keywords: VR, Virtual Reality, Game Development, unreal engine virtual reality, unreal engine vr, unreal engine vr tutorial, unreal engine, vr development, vr game dev, vr game development
Id: gUpjOrXFhIA
Channel Id: undefined
Length: 18min 14sec (1094 seconds)
Published: Sat Jan 28 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.