I’ve been trying forever to find the answer to this by searching, trial and error, and nothing works. This is the other thing I’ve been stuck on for several days, and the other one I finally got the answer from some great people here, so I’m hoping that someone can help me figure this one out.
I’m working on a project for which the player walks through a large room, with some frames, that when the user hovers over them with the crosshair and clicks the mouse left button, a widget opens in full screen mode. When the user clicks on the right button, it closes and goes back to the level.
We achieved this by doing a line trace for each frame, and then for the right click, we used a “remove all widgets” node. And that works for the most part, except for this: we need a permanent overlay on the bottom right of the screen (like those network channels use, such as ABC, FOX, etc).
At first, we were using a widget for this permanent overlay, placing the graphic close to the bottom right. The problem came when we tried to use the “Remove from parent” node to perform the right click action to remove the widget from the screen and unpause the game. It worked in preview, but it gave the dreaded “accessed none” error. Unfortunately, there is a node called “Add to viewport” but there’s no node called “Remove from viewport”, at least in 4.23, which is what we have to use to be able to export to HTML 5.
So what I did as a workaround was to insert, in the HUD blueprint, a draw texture node, that comes from an “event receive draw HUD”, and try different numbers in X and Y to achieve the position that I wanted for that texture.
So I thought that was the perfect solution because it was a HUD texture and not a widget, so when the user right clicked and that triggered a “remove all widgets”, the overlay stayed on screen.
What I didn’t realized, until my coworkers told me, is that the size of the game is totally different depending on the computer and monitor size. So the numbers I had entered as X and Y, which in my case put the overlay texture like the typical network channel logo, in other cases was totally absent, or it appeared closer to the center of the screen, because the X and Y origin starts from the top left of the screen.
So that leaves me with two possible ways to solve this, and days of searching this forum and other websites, YouTube and whatnot, hasn’t given me yet:
-
I find a way to change the origin from the default top left of the screen to the bottom right. This would be perfect.
-
I set the overlay as a widget again, but then I have to find a way to prevent that widget from closing by using the remove from parent node, and variables for each of the widgets that I do want to remove from the screen.
-
Some other way that probably I haven’t though of but more knowledgeable artists can tell me.
If anyone can give me any pointers I would be really grateful.