In Game Menu Widget will be loaded with an indefinite number of copies!

When I tried loading the in game menu using the action key multiple times, the widget would keep layering on the previous one. Nasty!

This can be prevented by separating the function that sets up the widget from the function that loads the widget, and calling the setup function separately in code. Also, a boolean is set when the widget is shown. The widget should be loaded once, preferably in BeginPlay (store a reference to the widget - return the widget pointer inside the loading function), and conditionally showing or hiding the widget when triggered by the keyboard event.

I did this in C++, here’s my repo.

As an added quirk, this also allows toggling the widget using the keyboard alone.

@sampattuzzi thanks for your response! :smiley:

P.S. I don’t think the keyboard binding should be shifted to the player character/controller’s InputComponent cuz it kinda breaks separation of concerns.

Your repository goes to a 404.

This is a good catch though.
I’ll post my solution here tonight, in this post.

EDIT : Actually, after thinking about this and reading the original code, not sure it’s possible to open multiple widgets in the lecture code. Since we are changing the input mode there’s no way to issue multiple open menu commands, at-least I couldn’t figure out a way. Perhaps you have more information on how you were able to issue multiple open in game menu commands?

Basically each time I was hitting the escape key, a new widget was overlaying itself on top of the previous one.

My repo was actually marked private, my bad :grimacing:

@SaxonRah you may want to try the DoOnce node.

While it’s not ideal, I don’t think it hurts the learning journey here. Inevitably some bug will get through.

1 Like

Privacy & Terms