Download

[SOLVED] Toggle actor visibility from a checkbox in a Pause Menu widget

I have a cube set up in my level. I want to toggle the visibility of it when the player checks a checkbox in a pause menu.

So far what I keep running into is:

  1. In the level BP, I can create a reference for the actor and even toggle the visibility of the actor, but not on the event that the checkbox is clicked.
  2. In the widget BP, I can give the checkbox some sort of functionality (I currently have is set up on a flipflop to toggle master audio on/off), but I can’t create a reference to the actor when I’m in the widget bp.

I’m not a code person, but if I had to guess it seems that the solution would be:

  1. as soon as the user clicks the checkbox, the cube is hidden
  2. on game resume, have the level bp run an is valid check to see whether or not the checkbox has been clicked; if yes = hide cube, if no = keep cube visible.

From all the failed google searches I’ve done so far, it feels I’m asking to do the impossible :confused:

On a side note: I did accidentally make the checkbox itself disappear once, gave me a good chuckle at my spectacular fail!

Edit: Changed the title for clarification.

Update: I haven’t figured it out just yet, but it seems there may be a potential solution in using an event dispatcher.

I followed a tutorial that covers what I’m trying to do using an event dispatcher to communicate between the widget bp and level bp, and think I have it set up correctly in the widget bp, and the second half of the level bp; I just don’t know what event to tie it to in the level bp since I don’t want the widget to immediately appear when the level loads. Any ideas?

Tutorial I’m following: https://www.youtube.com/watch?v=9uweDnKGbG8

Update #2: I found a solution! It wasn’t by using event dispatchers at all but rather cast to another blueprint. Basically what I did was gave my cube its own blueprint which I was then able to cast to from my widget blueprint, telling it to disappear when the user checks the checkbox. I don’t think I even needed to set up anything in the level bp.

When I open my level, I can now pause my game (which opens up my pause menu), and select a checkbox that toggles the visibility of a cube I have setup in the level.

This is just how I got it to work, but if there’s a better way to set this up, I’d love to hear it!