Unreal Engine: Creating a Keyboard/Gamepad Menu | Step-by-Step Guide

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

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

  • @cibe
    @cibe  2 года назад +4

    Anyway Thanks for watching guys, and i want to point out that you can directly hook the [vertical box -> get all children] to the for each loop instead of remapping it to a new array so you are saving yourself a forEach loop, some things in this tutorial can be achieved in different ways, as always when programming! You can also experiment with callbacks, interfaces or dispatchers to handle the Click Event on the menu, but anyway this should be sufficent for a Static Main Menu with a defined set of options! Don't forget to Share and Sub, and if you have any question Just ask Below, i'll respond as soon as i can.

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

      cast to button is failing

    • @VittorioBaldini1997
      @VittorioBaldini1997 8 месяцев назад +1

      CIAO! Sono sull'editor UE5.4.1 e ho seguito esattamente le tue istruzioni, ma qualcosa non sembra funzionare. Quando provo i pulsanti che mostri al minuto 25.10, semplicemente non funzionano e i pulsanti non vengono evidenziati. Cosa può essere? Mi sta facendo impazzire sta cosa

  • @rolfesbrent
    @rolfesbrent Год назад +8

    Thanks for the tutorial; helped me get basic functionality for the menu with the gamepad. One thing I learned is that you can use the 'listen for input' node inside your menu blueprint to get your input actions instead of using the keyDown function and hard coding all the buttons for your menu input. Note this doesn't work if you use UI only input mode or set game paused.

  • @-Chadnik
    @-Chadnik 11 месяцев назад +8

    Just in case anyone is having problems with the keyboard inputs not working a possible solution is that the "Is Focusable" option does not do what it should for you. There is probably a better way to solve this but i just created an "event tick" and connected it to "set keybaord focus" inside the widget and it works fine now.

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

      I put mine in the construct and it workes aswell :)

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

      Thank you very much for this!

  • @_Azzy_
    @_Azzy_ 4 месяца назад +2

    Worked just fine in U.E.5, ty so much!

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

    love the "I have a little bit of problem with the controller" and then *smack smack* (19:15)

    • @cibe
      @cibe  8 месяцев назад +1

      Ahaha Percussive maintenance ftw!

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

    You saved me and my project, thank you man

  • @VinoVenitas
    @VinoVenitas 7 месяцев назад

    Couldnt use all of it, but some of this was really helpful. Thanks for this. I had to figure a lot out because I made the buttons a widget as well. But this was useful.

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

    Thank you very much. great tutorial.

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

    This was a really good video. It is going to be a PAIN to add this to all my UI but will certainly be more than worth it.

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

    Hi there, great tutorial! Thanks for the help.
    I'm having some trouble with the workings of it though, can anyone shed a light please?
    The keyboard/gamepad integration is working wonders, however, when I click anywhere else on the screen, while the HUD Widget is open, other than the buttons themselves, I'm no longer able to move or register any of the keyboard/gamepad events.

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

    23:32 - This occurs because length for arrays starts at a 0. An example helps.
    If you have 4 items in an array, that array has 4 items in it. They are numbered 0, 1, 2, and 3.
    Let's say we start at Menu Navigation Index 3 (the last one).
    If you press up, the logic here is comparing the menu navigation you're trying to reach (index 3 + 1 = 4) to the length of the MenuItems (max length 4)
    Since the MenuNavigationIndex (4) is NOT greater than the MenuItemsLength (4), the branch will return false.
    This is REALLY BAD, because we're creating logic that grabs the item from MenuItems whose value corresponds to our MenuNavigationIndex
    Continuing the above example, 4 is not greater than 4 -> Grab the item at index (MenuNavigationIndex) from MenuItems = grab the item at Index 4 from MenuItems... which only has values at index 0, index 1, index 2, and index 3.
    Error, OutOfBoundsException, crash, bad times.
    This is why we subtract 1 from the MenuItems Length. Let's try again.
    Is our desired MenuNavigationIndex (4) less than the MenuItems Length - 1 (4-1 = 3)? Yes!
    Now the branch is true. This means we fix the MenuNavigationIndex, which means we never grab Index #4.
    No OutOfBounds, no crash, all good!

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

      Correct i got confused in the video, been programming for years and falling into such a stupid thing shame on me 💀
      Thanks for the detailed explanation!

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

      @@cibe no shame at all, video creation is hard. Harder when you're thinking at the same time.
      The comment was for other voewers who didn't understand. I figured you knew why :)

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

      @@itanocircus2077 Exactly! And totally shame on me ahah rewatching the videos i always see i make some mistakes, but that also good for me to improve!
      I know the comment was for the viewers, i love when people comment with detailed explanations because it helps everyone!

  • @Adouchamo
    @Adouchamo 10 месяцев назад

    THANK YOU FOR SHARING THIS VIDEO .. I LOVE IT

  • @The-Beeby
    @The-Beeby Год назад +2

    Hay for some reason doing this has stop my play character moving when going to the next level after play....any help would be great

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

      Its probably a focus issue try to switch game focus using the related blueprints

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

      Try game only or game and UI

  • @coolsachin2737
    @coolsachin2737 2 месяца назад +1

    Thank You

  • @cheshirekittinz17
    @cheshirekittinz17 10 месяцев назад

    To allow control back to the pawn you need to put a input gamecontrols before the level loads.

  • @보리타작-x9s
    @보리타작-x9s 2 года назад +1

    13:12 where set the MenuNavigationIndex ? If the function executed, equal Branch is only true "0". Cause Default is Zero. My Case is first button works but the others don't work. It seems to change right before button when i hovered it... Any Advice?

    • @보리타작-x9s
      @보리타작-x9s 2 года назад +1

      sovled ) I added Spacer not Padding. So I deleted Spacer it works :)

  • @nassergreatdeveloper3745
    @nassergreatdeveloper3745 7 месяцев назад

    Thank you, sir, which version of unreal engine do you work in?

    • @cibe
      @cibe  7 месяцев назад +1

      i believe this was 4.27 it was the version i used the most until UE 5.4 that now seems to be stable finally

  • @joe-9718
    @joe-9718 2 года назад +4

    Thanks for the effort, but I genuinely cannot believe that this is still a problem, and still absurdly difficult to set up this far into UE's development... How the heck are you supposed to make a dynamic inventory that works on gamepad, or a big settings menu? Hard coding everything individually like this just wouldn't work..
    Any possibility at all you could look into any method of making the assignments a bit less static and hard coded?

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

      Thats something i never tought about, and you are probably right that this tutorial is not suitable for something like that, my guess is probably using the index of an array containing all the items of the inventory, or controlling focus/tab focus to achieve something like that, if i figure it out, i'll definetly make a new tutorial.

    • @joe-9718
      @joe-9718 2 года назад

      @Cibe thanks for the response. Really appreciate your thoughts. But yeah I've never found a clean way to implement gamepad controls for something like that so I've always had to either forget about gamepad input or simplify my menus so much that they suck.

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

      About the keys hardcoding, in UE5 it is probably not necessary as you can now create Key Mappings context

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

      Hey, i got it with really few blueprints, i'll reply here with a link to the video as soon as i upload it! It is a very basic tutorial to get you started, so you will need to handle some stuff yourself, but it works, It is based on an array like i said before, So the logic will be -> You pick up an item, you add it to the Array -> you handle the inventory update visually by iterating the array or doing some diffing so you don't refresh the entire inventory visually each time, from here you can use the system coming with my next video that will allow you to navigate the inventory in every direction, you can make multiple items blueprints and each of them will have its own click logic

    • @joe-9718
      @joe-9718 2 года назад

      @@cibe Thank you so much for thinking into this! I really appreciate it! Thanks. I look forward to seeing your method :)

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

    Nice video, thank you! I have a (maybe stupid) question: why not using the focus status, is there a specific reason? Thank you!

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

      If you mean the "is Focusable" boolean, it's because it won't let you use the On Key Down override

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

      @@cibe thank you for your reply! I mean the default system that focuses automatically on the button for the button instead of hard coding the selection, is there a specific reason or it is just to have more control and flexibility?

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

      @@matteomaravalle5461 oh i get it now, yeah the standard focus is good for simple things, but on the long run if you need to achieve complex behaviours it is better to make a custom system, the standard focus system is kinda limited and not customizable

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

      @@cibe thank you it’s clear! ☺️

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

    This worked great, just have a problem. I created a "BACK" button for my credits. When I press on the credits button in the main menu, the credits open, but when in the credits, I can only go back to main menu if I hover over the back button with the mouse and click, but nothing happens with the gamepad? I duplicated the main menu widget, and made it credits, to have gamepad work with specific widgets without having to do all the code again. Is it because there's only 1 button in credits?
    (The back Button)

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

      I'm not quite sure if thats the case, but could be the same focus problem i was having, try to add a Set Keyboard Focus to your event constructor in each Widget that should work with keybord and mouse, if this is not the case the issue might be somewhere else.

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

      Could be that only one index breaks the system aswell, but i believe once you press a key it should enter the index 0 anyway and stay there, so might just be a focus problem in the end

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

      @cibe I'll give it a shot! Still a great tutorial, and worked well for the main menu part!

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

      @@cibe Yes! It worked! Thnx❤️❤️🙌🏾🙌🏾

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

      Just one more quick question. Have you ever figured out how to go left and right in menu with game pad, for if I had an options menu with buttons horizontal and verticle?

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

    I can't move forward up and down when i unpause for controller

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

    Great tutorial! Thanks! But there was a problem: if you go to another widget (for example options), and then go back to the main menu widget, the color of the buttons does not change (((

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

    How can you change to hovered image instead of just the background colour?

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

      You should use and target 2D Textures if i remember correctly

  • @Luke_wasd
    @Luke_wasd 11 месяцев назад +1

    And with Unreal Engine 5 i will take a look on build in plugin (just turned off) "Common UI Plugin" seems easier way to do it.

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

    Thank you very much. But Why I need to use mouse click into viewport once to toggle keyboard/gamepad input? Is there any solution?

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

      Actually, i'm facing the same issue on a project, it is a focus problem, i solved it by adding Set Keyboard Focus on Event Construct in the Menu UMG

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

    While this does the job well I'm honestly baffled by the complicacy of this. For example, I have multiple layers of UI and going by this approach I am now maintaining various variables holding the index of which part of UI is currently activated and then further variables holding the index of current selection.
    Did you find some other way for navigating using controllers and keyboards. I'm going to look into other tutorials after I post this comment. Anyway this is the first time I'm programming controller support so maybe that's why I'm finding it unreasonably complicated.
    I used to think you would just define which button is to the left and which is to the right. I was wrong on so many levels.

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

      It is unreal fault, however it probably can be easier on unreal engine 5 with controls mappings, but i have yet not tested this, as in my project i need to support ue4

  • @Luke_wasd
    @Luke_wasd 11 месяцев назад +3

    Thumbsitck dont working because u compare "Get Key" to "Gamepad left thumbstic Y-Axis" Not to "Left Thumbstick Down or Up" All You need is just search for left thumbstick down or up. instead of clicking on "icon" to assign button by detect.

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

      Thanks, i realized this later on

    • @chepchelinka7200
      @chepchelinka7200 4 месяца назад

      Thanks❤‍🔥

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

    I don't get it. Why do you need to do all of that when you can simply use {SetKeyboardFocus()} ? The navigation will work fine using this. But, if I'm not mistaken, it will only work when using gamepad (not ps4/ps5 by default - these will need further work using raw input plugin), and not when using keyboard arrow keys.

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

      can you elaborate a bit more?

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

      @@kingalonsoiv Sorry for being late. On Unreal Engine UMG, the gamepad (Xbox by default) works great with navigation, and button click detection (Using A button). The work around is simply by using Button->SetKeyboardFocus();
      It's not as easy when to comes to a more complicated UMGs, for example you need to change the Focus based on the Menu the player is currently in, but that's not a big issue, the input detection such as Y,X,B for opening or closing sub-menus, or navigate back, and so on (You can do whatever you want), can be easily done with something like the OnKeyDown Overridden Event, and there's more events for that depends on the situation of the UMG.
      One down side though, is the lack of support for the RawInput plugin for when it comes to detecting if player is using a gamepad (GenericUSBController__) keys are registered as a keyboard input, not a gamepad, but that can easily be fixed by changing the source code, though, still not done yet; The UMG won't work still when using RawInput Plugin.
      If you need the best UMG results using a gamepad like Xbox, I suggest you to use the CommonInput Plugin, it'll make a lot of impossible things to be possible, and make your developing journey a lot easier.
      Currently I can use Xbox controllers in-game and in-umg, as well as the RawInput Plugin, I succeeded to make it work with DualSense and DualSense Edge/ DualShock controllers of all versions (ps4,ps5), in-game, the only issue for these is the UMG, I'm still not sure how make this work perfectly but; I'll change the source code of CommonInput Plugin, and make a new device type to be RawInput, and from there I'll also make my own code to detect what controller the player is using, with it's Full-Name using the VID & PID, from there I think I'll be able to make a functionality in my ButtonBase class and in case the player was using RawInput (inside the on key down event, etc) then depending on the button he clicks, say he clicked X (same as A button on Xbox), then I call a broadcast to trigger the on clicked event, I'll also make it to work with navigation as well when player moves L3 up/down/left/right, and perhaps R3 as well, using the navigation call in the button it self inside the UMG editor, in addition to the Menu Input Icons, currently I've support for KBM/Xbox, but I'll add a 3rd type for both Ps4/Ps5 controllers.
      I may build the whole system again which is a long run, but I may end up making it a small plugin so I can use it on any project I'll build in the future!
      Good Luck.

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

      ​@@MahdiAbuHamida_wow, thank you very much, this has been very helpful

    • @Icantinkrnlmao
      @Icantinkrnlmao 10 месяцев назад

      @@MahdiAbuHamida_ wow man you dont know how much this helped me in my project, love you dude

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

    Thank u

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

    30:55 you're doing an == for every index, which is suuuper inefficient.
    I'd just use a Switch on Int if you're going to do it that way.
    Edit a few seconds later: Nevermind, you did just that. Lol

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

      You are right, the switch is a better option

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

    Hello friend can you continue with the tutorial on how to control widget making a configuration menu, how to move with the joystick or control L1 and L2 change the screen modes or lower the volume, and how to hide the mouse if you are with the gamepad when it detects it or you move any button and if you move the mouse the mouse is displayed, and when you switch between widget how not to lose the Focus and continue controlling with the gamepad, can you do or know how to do it, I would greatly appreciate a tutorial.🤗✌️✌️✌️✌️

    • @SilverScriptGames
      @SilverScriptGames 10 месяцев назад

      the joystick you can map with "gamepad left thumbstick up" or "gamepad left thumbstick down" rather than the axis options which don't help in this case :)

  • @georgebradley6521
    @georgebradley6521 7 месяцев назад

    in Unreal 5 the solution seems to no longer work

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

    Is this UE 3?

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

      No? Unreal 4.27.2

  • @reyshakquit
    @reyshakquit Месяц назад

    ON PREVIEW DOWN works way better than ON KEY DOWN

  • @elgrekko9634
    @elgrekko9634 Год назад +5

    Shame of you Epic Games Inc. ! Why is so hard to use a basic gamepad in menu ! With movement of the character it's so easy, project settings/inputs then Axis/Action Mapping and THAT'S ALL ! Do the same thing for widgets and their buttons and sliders ! Never see that ! Sometimes I work in Unity, more simple but no blueprint ! (not yet) ! They want you pay any expensive plugin on the epic marketplace, and even with that, some buttons or sliders doesn't work every time ! Anyway...

    • @nassergreatdeveloper3745
      @nassergreatdeveloper3745 7 месяцев назад

      man you are right. Epic game is focusing in just graphics and they do not improve saving and loading system or widget blueprint. there is new what is called UI common, but there is no enough documents about

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

    One of the worst tutorials I have ever watched. I mean he changed what he was doing 3 times!

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

      Lmao, Thats how you improve things

    • @tahmidtarique6077
      @tahmidtarique6077 8 месяцев назад +1

      @cibe You can make dozens of the same video, but with different ways! Anyway, mine doesn't work after the build.

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

      @@tahmidtarique6077 do you get any errors?

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

      also make sure to give focus to the keyboard as i pointed in other comments

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

      @cibe No errors, but I had to delete the top part after the click event you had made because it stopped my game from working. After building, the arrows move the character, but not the buttons.