This is a simple solution to a problem that may work 90% of the time but it is not modular enough. For example if you want to allow the user to remap the inventory key, you can't do that this way, unless you have a configurable variable which will be different from the input mapping context. Generally a better (IMO) idea would be to handle the interaction from where you trigger the inventory event. That being said, if you want to handle inventory access in all characters, i guess you could place it in player controller - or - an even better approach would be to create an actor component, call it "WithInventoryAccess" & attach "WithInventoryAccess" component to any characters you want them to have access to the inventory. I think you guessed already that I am a big fan of the enhanced input system in 5.1 :P That being said, that's one clever way to solve a problem if you don't mind modularity. Kudos to that!
The way I do it is that I implement a player pawn that I possess when the player is using the UI. That player pawn handles the IMC and the inputs. I then create an event dispatcher for each input. In my widget, I use get player pawn, cast it to my pawn, and then bind the created events. I'm not sure this is the cleanest way, but at least you can remap the keys through your IMC.
I really wish the widget system would be given Native Keybinding support. I just feel like the way they handle input actions for Widgets needs a serious overhaul.
If you know how it works, its really really easy, and "CommonUI" made it so much easier. i had no issues to just set up my widget and it worked with controller out of the box.
I think I found a way to use this with the enhanced inputs and be remappable / non-context specific. First get a reference to the enhanced input local player subsystem, then 'query keys mapped to action' for the specific action you want. That returns an array of keys mapped to the specific action. Then loop over the array checking if the key down equals one of the keys mapped to the action you are checking. I added a local bool to hold the result. Then branch and handle after that.
This is exactly what I was looking for, thank you! I didn't realize you could just get the subsystem and query it. Instead of using a loop, however, I used the "contains" node to check if they key event was in the array, which saves using a bool and seems to work well.
I know its a bit of a necro but more people should be talking about this. While its a bit more messy it uses the IA system the way it should be used. That way the user can easily change keys without finding weird bugs like the video above suggested. Thank you!
When I use the Array Contains Its returning a bool value, how does this save using a bool ? u still have to loop the array return to get the key structure it seems like to me@@ChanceBrunton
@@ryanjdev87 why would you get the key structure? you only want to know if the pressed key is one of the assigned keys to the input action you want triggered, so when the bool is true you simply implement whatever you want to be done when the key is pressed.
Save our eyes. Please Disable Motion Blur :) 1. Go to the "Settings" > "Project Settings" > "Rendering" > "Post Processing" 2. Uncheck the "Motion Blur" option and Save/Rebuild lighting
I was actually just thinking how I could accomplish this while chilling. I couldn’t figure it out from a theoretical standpoint, so I chalked it up to something I would cross when I get there in my game but your read my mind! Thank you my man! Cheers 🍻
Hey Matt great stuff, but I have a question. Have you played w/ using the new 5.1 Input Mapping Contexts for this? I was playing with having TWO contexts: one for game, and one for UI, and then rather than setting the mode to "UI Only" I set it to "Game and UI" and then remove the game input context and add the umg input context. (And then when the widget/menu is closed I reverse the process). Doing the Game and UI mode DOES fire the Input actions in the widget (It just doesn't if you're in UI only mode), so by swapping mapping contexts it's sort of a cheat to get a set of unique inputs into UMG. I've done a Proof-of-concept w/ this and it works but I don't know if there are any gotchas or if this a bad idea for some reason I don't know, so was wondering if you've tried that or have any thoughts on it? Cheers.
Interesting idea, I haven’t tried that myself but it sounds great! I think you are definitely utilising it how Unreal planned, so great work. As of right now I can’t think of any “gotcha’s” with this system, other than maybe making sure you’re always changing the mapping context of the correct player controller. Nice work!
Very cool. The video is nice and crisp. I think what looks like lag is just motion blur in the engine or maybe that level is very demanding graphics wise. The sound seemed clearer as well.
Thank you, Matt! Yeah, I had the feeling this feature was designed for controllers only. You switch between input contexts (for gameplay and UI) and link input actions to different delegates/events. It's more limited but perhaps for the better. And about the video, it looks good on my screen.
It can be used for both PC and controller yep. Like you say, it has it's limitations - but there are use cases where you'd want it! Thanks for the feedback on the video too!
@@MattAspland Sorry, English is not my first language. I could have put that better. When I mentioned controllers, I was referring to character controllers (or the character itself like you do). I think it's a great system and is better than the old one.
Probably should let people know if you override a widgets function with a remove parent node, it will affect that WBP where ever it is. As in. Say you are using your inventory WBP for its purpose in game like that but you also, for what ever reason also use it from your mainmenu WBP. Pressing tab in there will also destroy the parent. In other words if anyone is watching this tutorial, its intended for a inventor WBP ONLY. dont use overrides if you are trying to get similar results for a ingame press escape key for a ingame menu system. Thought i should point that out for the timmys out there lol.
Hey, quick question, how would you go about setting this up if I was applying it to a differnt type of menu to instead use the mouse scroll wheel instead of the cursor?
OK this is great and everything, but what if you want the player to be able to remap those keys? How do you grab information from an Enhanced Input Action, such as its trigger keys/buttons?
For games like assassin’s creed and others when you open inventory, equipment , map or any widget the game paused , I usually call the function set game paused I haven’t seen any video mentioning that
The OnKeyDown event won't trigger unless I am clicking and holding down on a button. Any idea why? Edit: I'm dumb and didn't watch the whole video, in case anyone else does the same thing, set "is focusable" to true!
Is it possible to use Enhanced (or casual) input instead? I have a complex system in my UI so with this method I will have to create a BIG stair of branches, which is not quite convinient
I've been trying to find a tutorial for how to use key bindings to select and switch between onscreen widget components within a widget (for instance if not using a mouse at all, and using arrow keys or joystick to go up/down/left/right selecting options and enter key or A button to confirm the selection), but I haven't had much luck in finding something like that. It would be awesome if you had a tutorial for how to do that, because in my opinion yours are the best and easiest tutorials to follow.
I have a tutorial screen with text to pop up and remove it when the player press any key. This works with any keyboard or controller key but not with a mouseclick. I tried to override the function "OnMouseButtonDown" and copy the nodes but for some reason it doesnt trigger this override?!
hi error showing during packaging LogPlayerController: Error: InputMode:UIOnly - Attempting to focus Non-Focusable widget SObjectWidget [Widget.cpp(954)]! Plz let me know how to fix the above error
Can i connect input key and widget button same thing? For example press ''p'' input key its pause and unpause game. When press p open ''pause menu'' it has ''continue'' widget button. I want, when press contiune button its activate input key ''p''.then unpause game again.
I am trying this to show main menu and pause game. At first I press P, all good... menu appears and pause work. I press P again to unpause... menu disappears but game is paused... I press one more time P and the game starts to play.... using UE5.3
I had the issue that when I clicked anywhere when the widget was opened, no input would work anymore, and I couldn't close the widget. To avoid this problem, you need to go to your Canvas Panel in the Designer, and set the visibility to "Visible" instead of "Not Hit-Testable".
The example I gave in this video is just one example, people may want to use inputs in a widget for a variety of different reasons. And again, sometimes you don't have control of your other blueprints anymore to use the input there. This video is just a way for people to have an input detected in a widget, for whatever reason they want. Remapping the action keys would take different code, for example you could promote the value in the "==" to a variable and set this variable through an external blueprint which is linked to your key mappings.
That's just my recording settings, it was running smoothly for me - it just didn't get recorded as smooth. I'm working on those settings now and I think I've fixed it.
This is a simple solution to a problem that may work 90% of the time but it is not modular enough. For example if you want to allow the user to remap the inventory key, you can't do that this way, unless you have a configurable variable which will be different from the input mapping context.
Generally a better (IMO) idea would be to handle the interaction from where you trigger the inventory event.
That being said, if you want to handle inventory access in all characters, i guess you could place it in player controller - or - an even better approach would be to create an actor component, call it "WithInventoryAccess" & attach "WithInventoryAccess" component to any characters you want them to have access to the inventory.
I think you guessed already that I am a big fan of the enhanced input system in 5.1 :P
That being said, that's one clever way to solve a problem if you don't mind modularity. Kudos to that!
You can now use input events inside an actor component.
The way I do it is that I implement a player pawn that I possess when the player is using the UI.
That player pawn handles the IMC and the inputs.
I then create an event dispatcher for each input.
In my widget, I use get player pawn, cast it to my pawn, and then bind the created events.
I'm not sure this is the cleanest way, but at least you can remap the keys through your IMC.
I really wish the widget system would be given Native Keybinding support. I just feel like the way they handle input actions for Widgets needs a serious overhaul.
If you know how it works, its really really easy, and "CommonUI" made it so much easier. i had no issues to just set up my widget and it worked with controller out of the box.
This is pretty neat, and works with the new enhanced input system too!
I think I found a way to use this with the enhanced inputs and be remappable / non-context specific.
First get a reference to the enhanced input local player subsystem, then 'query keys mapped to action' for the specific action you want.
That returns an array of keys mapped to the specific action. Then loop over the array checking if the key down equals one of the keys mapped to the action you are checking. I added a local bool to hold the result.
Then branch and handle after that.
This is exactly what I was looking for, thank you! I didn't realize you could just get the subsystem and query it. Instead of using a loop, however, I used the "contains" node to check if they key event was in the array, which saves using a bool and seems to work well.
I know its a bit of a necro but more people should be talking about this. While its a bit more messy it uses the IA system the way it should be used. That way the user can easily change keys without finding weird bugs like the video above suggested. Thank you!
When I use the Array Contains Its returning a bool value, how does this save using a bool ? u still have to loop the array return to get the key structure it seems like to me@@ChanceBrunton
@@ryanjdev87 why would you get the key structure? you only want to know if the pressed key is one of the assigned keys to the input action you want triggered, so when the bool is true you simply implement whatever you want to be done when the key is pressed.
This worked for me!
I'm stuck exactly for this issue. Why we can't use Key bindings in Widget is a mystery for me. thanks a lot for the tutorial.
Been looking for this functionality for weeks! Once again, can't thank you enough
Happy to help!
Save our eyes. Please Disable Motion Blur :)
1. Go to the "Settings" > "Project Settings" > "Rendering" > "Post Processing"
2. Uncheck the "Motion Blur" option and Save/Rebuild lighting
I think it was more my recording than motion blur - but noted!
you sir knows our noobs need, thank you for another excellent first class tut!
I was actually just thinking how I could accomplish this while chilling. I couldn’t figure it out from a theoretical standpoint, so I chalked it up to something I would cross when I get there in my game but your read my mind! Thank you my man! Cheers 🍻
Great to hear, happy to help!
Hey Matt great stuff, but I have a question. Have you played w/ using the new 5.1 Input Mapping Contexts for this? I was playing with having TWO contexts: one for game, and one for UI, and then rather than setting the mode to "UI Only" I set it to "Game and UI" and then remove the game input context and add the umg input context. (And then when the widget/menu is closed I reverse the process). Doing the Game and UI mode DOES fire the Input actions in the widget (It just doesn't if you're in UI only mode), so by swapping mapping contexts it's sort of a cheat to get a set of unique inputs into UMG. I've done a Proof-of-concept w/ this and it works but I don't know if there are any gotchas or if this a bad idea for some reason I don't know, so was wondering if you've tried that or have any thoughts on it? Cheers.
Interesting idea, I haven’t tried that myself but it sounds great! I think you are definitely utilising it how Unreal planned, so great work. As of right now I can’t think of any “gotcha’s” with this system, other than maybe making sure you’re always changing the mapping context of the correct player controller. Nice work!
Thanks so much for this 🙏
Life saver as usual
Great video!
I was trying to jsut get input normaly for more than an hour. Thank you
Yesss I needed this but couldn't find it anywhere. Thanks!
Glad I could help!
Another great tutorial bro! I've been here for a long while and it's literally awesome to see how far you've made it!
Thank you so much! I really appreciate it!
How did you make InputAction Inventory?
this is just right for my game and with fewer steps than my code. Thank you!
Perfect!
thanks for the awesome video🙌
Thank you! You're the best!
Very informative. Thank you soo much
My pleasure!
Very cool. The video is nice and crisp. I think what looks like lag is just motion blur in the engine or maybe that level is very demanding graphics wise. The sound seemed clearer as well.
Thanks for the feedback Patrick! Much appreciated! I’ve fine tuned my settings more tonight so hopefully next video is even better!
Thank you, Matt!
Yeah, I had the feeling this feature was designed for controllers only.
You switch between input contexts (for gameplay and UI) and link input actions to different delegates/events.
It's more limited but perhaps for the better.
And about the video, it looks good on my screen.
It can be used for both PC and controller yep. Like you say, it has it's limitations - but there are use cases where you'd want it!
Thanks for the feedback on the video too!
@@MattAspland Sorry, English is not my first language. I could have put that better.
When I mentioned controllers, I was referring to character controllers (or the character itself like you do).
I think it's a great system and is better than the old one.
Ah right I get you, no worries!
tnx for this is focusable... means a lot
You're a legend
Probably should let people know if you override a widgets function with a remove parent node, it will affect that WBP where ever it is. As in. Say you are using your inventory WBP for its purpose in game like that but you also, for what ever reason also use it from your mainmenu WBP. Pressing tab in there will also destroy the parent. In other words if anyone is watching this tutorial, its intended for a inventor WBP ONLY. dont use overrides if you are trying to get similar results for a ingame press escape key for a ingame menu system. Thought i should point that out for the timmys out there lol.
Thanks a lot for your works
Hey, quick question, how would you go about setting this up if I was applying it to a differnt type of menu to instead use the mouse scroll wheel instead of the cursor?
I hope u bring us a way to do this with new mapping contexts
So Thank, UserWidget Input
OK this is great and everything, but what if you want the player to be able to remap those keys? How do you grab information from an Enhanced Input Action, such as its trigger keys/buttons?
Create a subsystem that can hold key bindings
For games like assassin’s creed and others when you open inventory, equipment , map or any widget the game paused , I usually call the function set game paused
I haven’t seen any video mentioning that
The OnKeyDown event won't trigger unless I am clicking and holding down on a button. Any idea why?
Edit: I'm dumb and didn't watch the whole video, in case anyone else does the same thing, set "is focusable" to true!
Is it possible to use Enhanced (or casual) input instead? I have a complex system in my UI so with this method I will have to create a BIG stair of branches, which is not quite convinient
Thank you!
looks fine to me the recording you did, I don't have 4K or the latest tv screen.
Quality wise looks good, it is a little laggy though
Thanks for the feedback, I think I may have some better settings now - we can see on my next upload!
I'm confused, I use inputs (old style and enhanced) in widgets, I've never had an issue. I feel like I'm missing something here.
I've been trying to find a tutorial for how to use key bindings to select and switch between onscreen widget components within a widget (for instance if not using a mouse at all, and using arrow keys or joystick to go up/down/left/right selecting options and enter key or A button to confirm the selection), but I haven't had much luck in finding something like that.
It would be awesome if you had a tutorial for how to do that, because in my opinion yours are the best and easiest tutorials to follow.
Hi can you make a video on how to apply damage with spells like fire ball, lightning, explosions and other vfx?
Thanks for this! How do you hide the widget when the stamina = 100?
Does anyone know where this map is from? Or what assets / packs were used to make it? Thanks
I have a tutorial screen with text to pop up and remove it when the player press any key. This works with any keyboard or controller key but not with a mouseclick. I tried to override the function "OnMouseButtonDown" and copy the nodes but for some reason it doesnt trigger this override?!
hi
error showing during packaging
LogPlayerController: Error: InputMode:UIOnly - Attempting to focus Non-Focusable widget SObjectWidget [Widget.cpp(954)]!
Plz let me know how to fix the above error
Any idea why the on key down node isn't receiving any input?
Hey Matt Can you make how to an inventory system please.
like resident evil style or basic
No fking way, finally.
Will check it out later, proba ly something obvious again and I was lazy to trt even
Can i connect input key and widget button same thing? For example press ''p'' input key its pause and unpause game. When press p open ''pause menu'' it has ''continue'' widget button. I want, when press contiune button its activate input key ''p''.then unpause game again.
It doesn't work with the arrow keys. With the rest it does. But I need to check if those specific keys are pressed.
I am trying this to show main menu and pause game. At first I press P, all good... menu appears and pause work.
I press P again to unpause... menu disappears but game is paused... I press one more time P and the game starts to play.... using UE5.3
I had the issue that when I clicked anywhere when the widget was opened, no input would work anymore, and I couldn't close the widget. To avoid this problem, you need to go to your Canvas Panel in the Designer, and set the visibility to "Visible" instead of "Not Hit-Testable".
ok what the purpose if I can close it normally from outside the widget!? and what If I want to remap the action keys
The example I gave in this video is just one example, people may want to use inputs in a widget for a variety of different reasons. And again, sometimes you don't have control of your other blueprints anymore to use the input there. This video is just a way for people to have an input detected in a widget, for whatever reason they want. Remapping the action keys would take different code, for example you could promote the value in the "==" to a variable and set this variable through an external blueprint which is linked to your key mappings.
i cant understand why, the input is changing back to game only but the widget is not closing from the screen ((
Thankyou
Only shows to switch between Game Mode and Widget. Still doesn't show how to use keys to navigate inside of Widgets
This doesn't work for me for some reason, A little help? It's pretty much the same as the one you made in the video
Actually I didn't see any difference between this way of recording and the old one. But if it works for you then keep it.
inventory wont close.
Vid is little laggy on the phone, will check on pc.
seems to be pretty laggy ingame
That's just my recording settings, it was running smoothly for me - it just didn't get recorded as smooth. I'm working on those settings now and I think I've fixed it.
blurred screen!