I’m creating an inventory system and I’m trying to find a way to toggle the inventory by pressing the tab key. I think I’ve almost got it working after a few hours of headaches, but the Inventory Open variable that I’m trying to cast to the widget wants to stay false even though I’m setting it to true in my character blueprint. I’m probably just doing something stupid here with the reference I made but I’d really appreciate some help.
The problem is that I’m not sure there is a way to use an input action inside the widget. I hate using the tick event but its the only thing that’s had even a little bit of success for me
Not sure whats wrong but if I were you i would try to get it working without invokving the tick event and just use input actions or widget click handlers.
Oh but there is! On construct event you can bind Event Handlers by name to those input actions (plug the red pin on the left side to a custom event and that event would be triggered by that input action as long as nothing else consumes the input action first)
UMG receives input actions before player controllers do. I have used this method successfully to overcome having to use Tick. I feel like it gave me more control over the flow and scope of execution.
hello. i think the issue is with the event tick section because when ever the widget is created , event tick continuously keeps on running there by setting the value to false, even though you are setting it to true in the character blueprint. so it will always be false because of the event tick which is continuously setting it to false.
Can you please explain what you mean by binding event handlers by name?
I don’t think that will work for me because I’m using Set Input Mode UI Only, which is stopping my input events in the characterBP from working until it gets closed.
whats the specific node called that i should use?
Still need help.
Hi, when in UI only mode the Was Just Pressed does not work, what you need to do is handle the on Key down but fist you need to make your widget Focusable
Then you need to override the OnKeyDown function by going to the widgets graph then click on AddNew >> Override function >> OnKeyDown. Inside the function you need to verify which key was pressed if for example == to TAB you can remove the widget or in your case Toggle Inventory.
That’s it, feel free to ask anything. Good luck.
Worked Perfectly, you’re a life saver
You’re welcome.
Sorry I remembered the node name wrong. Here’s a screenshot from one of my widgets:
You would put something like “Inventory” or “Use” or whatever your Input Action is named, for the Action Name pin, and instead of DpadUnfreeze you’d probably call your customevent something like UseInventory or something.
That’s the best way to go about it but unfortunately it doesn’t work in UI only mode.
Oh yeah i forgot about that!