How To Use Input Keys Inside Of Widgets In Unreal Engine 5 (Tutorial)

Поделиться
HTML-код
  • Опубликовано: 9 янв 2025

Комментарии • 85

  • @Yorgarazgreece
    @Yorgarazgreece 2 года назад +33

    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!

    • @MirrorsEdgeGamer01
      @MirrorsEdgeGamer01 Год назад +1

      You can now use input events inside an actor component.

    • @Helgrind44
      @Helgrind44 6 месяцев назад +1

      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.

  • @unrealdevop
    @unrealdevop 11 месяцев назад +18

    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.

    • @Punisher1992
      @Punisher1992 22 дня назад

      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.

  • @tastysnak
    @tastysnak 2 года назад +6

    This is pretty neat, and works with the new enhanced input system too!

  • @Rukhd4Games
    @Rukhd4Games Год назад +27

    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.

    • @ChanceBrunton
      @ChanceBrunton Год назад +3

      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.

    • @rogerfoster8020
      @rogerfoster8020 Год назад +2

      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!

    • @ryanjdev87
      @ryanjdev87 11 месяцев назад

      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

    • @mh518
      @mh518 8 месяцев назад

      @@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.

    • @boggledeggnoggler5472
      @boggledeggnoggler5472 5 месяцев назад

      This worked for me!

  • @alexrybin3798
    @alexrybin3798 8 месяцев назад +2

    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.

  • @chrischandras3390
    @chrischandras3390 2 года назад

    Been looking for this functionality for weeks! Once again, can't thank you enough

  • @tacolover619
    @tacolover619 2 года назад +2

    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

    • @MattAspland
      @MattAspland  2 года назад +1

      I think it was more my recording than motion blur - but noted!

  • @solideogloria5553
    @solideogloria5553 Год назад

    you sir knows our noobs need, thank you for another excellent first class tut!

  • @donhoolieo4896
    @donhoolieo4896 Год назад

    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 🍻

  • @colonelb
    @colonelb 2 года назад +7

    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.

    • @MattAspland
      @MattAspland  2 года назад +2

      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!

    • @dimokol
      @dimokol Год назад +1

      Thanks so much for this 🙏

  • @AlyrioNeto
    @AlyrioNeto Год назад

    Life saver as usual

  • @BenskiGameWorks
    @BenskiGameWorks 5 месяцев назад

    Great video!
    I was trying to jsut get input normaly for more than an hour. Thank you

  • @dasistwalter96
    @dasistwalter96 2 года назад

    Yesss I needed this but couldn't find it anywhere. Thanks!

  • @KGCofficial7
    @KGCofficial7 2 года назад

    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!

    • @MattAspland
      @MattAspland  2 года назад

      Thank you so much! I really appreciate it!

  • @gamersbyknight9515
    @gamersbyknight9515 Год назад +2

    How did you make InputAction Inventory?

  • @pabloa4672
    @pabloa4672 Год назад

    this is just right for my game and with fewer steps than my code. Thank you!

  • @manasjoshi2939
    @manasjoshi2939 Год назад

    thanks for the awesome video🙌

  • @agha809
    @agha809 8 месяцев назад

    Thank you! You're the best!

  • @rifat.ahammed
    @rifat.ahammed Год назад

    Very informative. Thank you soo much

  • @PatrickTheDM
    @PatrickTheDM 2 года назад

    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.

    • @MattAspland
      @MattAspland  2 года назад

      Thanks for the feedback Patrick! Much appreciated! I’ve fine tuned my settings more tonight so hopefully next video is even better!

  • @aleca8910
    @aleca8910 2 года назад

    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.

    • @MattAspland
      @MattAspland  2 года назад +1

      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!

    • @aleca8910
      @aleca8910 2 года назад +1

      @@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.

    • @MattAspland
      @MattAspland  2 года назад

      Ah right I get you, no worries!

  • @jrshe3330
    @jrshe3330 Год назад

    tnx for this is focusable... means a lot

  • @ericdrob
    @ericdrob Год назад

    You're a legend

  • @DEM1GOD7
    @DEM1GOD7 6 месяцев назад

    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.

  • @mrbah7462
    @mrbah7462 Год назад

    Thanks a lot for your works

  • @Zeryphim
    @Zeryphim 5 месяцев назад

    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?

  • @carlosrivadulla8903
    @carlosrivadulla8903 2 года назад

    I hope u bring us a way to do this with new mapping contexts

  • @안성훈-g2e
    @안성훈-g2e Год назад

    So Thank, UserWidget Input

  • @Xylot
    @Xylot Год назад +1

    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?

  • @georgearida4144
    @georgearida4144 2 года назад +1

    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

  • @feraly7506
    @feraly7506 5 месяцев назад +1

    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!

  • @ShamaxGD
    @ShamaxGD Год назад

    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

  • @nick_the_octopus
    @nick_the_octopus Год назад

    Thank you!

  • @MartKart8
    @MartKart8 2 года назад

    looks fine to me the recording you did, I don't have 4K or the latest tv screen.

  • @darkwolf780
    @darkwolf780 2 года назад +3

    Quality wise looks good, it is a little laggy though

    • @MattAspland
      @MattAspland  2 года назад +2

      Thanks for the feedback, I think I may have some better settings now - we can see on my next upload!

  • @learningdev1315
    @learningdev1315 2 года назад +1

    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.

  • @KratonWolf
    @KratonWolf Год назад +1

    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.

  • @boristrendafilov2243
    @boristrendafilov2243 Год назад

    Hi can you make a video on how to apply damage with spells like fire ball, lightning, explosions and other vfx?

  • @TheBrassGoblin762
    @TheBrassGoblin762 Год назад

    Thanks for this! How do you hide the widget when the stamina = 100?

  • @srawdawg6188
    @srawdawg6188 Год назад

    Does anyone know where this map is from? Or what assets / packs were used to make it? Thanks

  • @Starblendet
    @Starblendet Год назад

    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?!

  • @AdireetiVlogs
    @AdireetiVlogs Год назад

    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

  • @wojtekgaming6760
    @wojtekgaming6760 Год назад

    Any idea why the on key down node isn't receiving any input?

  • @burakucpnar4965
    @burakucpnar4965 2 года назад

    Hey Matt Can you make how to an inventory system please.
    like resident evil style or basic

  • @gamerdweebentertainment1616
    @gamerdweebentertainment1616 2 года назад

    No fking way, finally.
    Will check it out later, proba ly something obvious again and I was lazy to trt even

  • @EvrenSaracgilArchitecture
    @EvrenSaracgilArchitecture 2 года назад

    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.

  • @roc6457
    @roc6457 Год назад

    It doesn't work with the arrow keys. With the rest it does. But I need to check if those specific keys are pressed.

  • @virtuaalruum
    @virtuaalruum 3 месяца назад

    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

  • @raconte-moiunehistoire756
    @raconte-moiunehistoire756 Год назад

    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".

  • @makadi86
    @makadi86 2 года назад

    ok what the purpose if I can close it normally from outside the widget!? and what If I want to remap the action keys

    • @MattAspland
      @MattAspland  2 года назад

      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.

  • @PikBo100
    @PikBo100 Год назад

    i cant understand why, the input is changing back to game only but the widget is not closing from the screen ((

  • @ArtofWEZ
    @ArtofWEZ 2 года назад

    Thankyou

  • @thelostsoul9497
    @thelostsoul9497 Год назад

    Only shows to switch between Game Mode and Widget. Still doesn't show how to use keys to navigate inside of Widgets

  • @Nexus-Point
    @Nexus-Point Год назад +1

    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

  • @onebuckgames
    @onebuckgames 2 года назад

    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.

  • @YugesBoys
    @YugesBoys 11 месяцев назад

    inventory wont close.

  • @budpeetie6879
    @budpeetie6879 2 года назад

    Vid is little laggy on the phone, will check on pc.

  • @b4ttlemast0r
    @b4ttlemast0r 2 года назад

    seems to be pretty laggy ingame

    • @MattAspland
      @MattAspland  2 года назад

      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.

  • @aasia-khan
    @aasia-khan 6 месяцев назад

    blurred screen!