# Toggle visibility between two UMG images with one key

**URL:** <https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461>\
**Category:** UI\
**Tags:** visibility, keybindings, unreal-engine, nodes, question, UMG\
**Created:** [June 21, 2017, 8:13pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461 "2017-06-21T20:13:56Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lauterdale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lauterdale](https://forums.unrealengine.com/u/Lauterdale)\
**Post date:** [June 21, 2017, 8:13pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/1 "2017-06-21T20:13:56Z")

</div>

I’m currently trying to toggle visibility between two images that are in my main HUD. They’re held within their own separate vertical boxes, named **gOd Drill Box** , and **gOd Gun Box** respectively. (gOd = gun OR drill)

On the Widget-side, both boxes are set to **hidden** , while their children images are set to **visible**.

The highlighted area in the image below is the current (non-functioning) setup I have.

 ![191010-before.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/4/9/949cce06e737524612efc77f6c9bea466c6a4c04.png)

I think it’s important to point out that both the **InputAction Swap** and the **Q Input** below it share Q as a keybinding.

**InputAction Swap** sets up the condition for the **Branch** to the right of it, where my left mouse button plays one of my drill melee animations on **True** , or my gunfire animation on **False**. These are working very well, so I tried to follow the same logic in setting the visibility for the image display on my HUD.

I’ll include both of the Widget images to give as clear a picture as I can:

Main Drill:

![191011-maindrill.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/5/1/05191ed6104ad047b350d47e32ea026415305bfb.png)

Main Gun:

![191012-maingun.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/6/f/36f99bd6acbd781dd1bae706afc5961cd2a32e99.png)

Thank you!

---

<div class="post-metadata">

**Author:** ![Lauterdale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lauterdale](https://forums.unrealengine.com/u/Lauterdale)\
**Post date:** [June 23, 2017, 5:44pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/2 "2017-06-23T17:44:54Z")

</div>

Bump, hoping for some kind of hint.

---

<div class="post-metadata">

**Author:** ![a\_nde](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a\_nde](https://forums.unrealengine.com/u/a_nde)\
**Post date:** [June 23, 2017, 10:10pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/3 "2017-06-23T22:10:57Z")

</div>

Hi Lauterdale,  
I think what u are looking for is the FlipFlop-node. It toggles between two execution wires. So when u click Q once, u set the visibility of one image to visible and directly after that the other one to hidden. Other way around for the second execution pin.  
cheers

---

<div class="post-metadata">

**Author:** ![Lauterdale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lauterdale](https://forums.unrealengine.com/u/Lauterdale)\
**Post date:** [June 24, 2017, 5:16pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/4 "2017-06-24T17:16:58Z")

</div>

Hey, man! Thanks for the response. Sorry on getting back to you so late. I tried (I think) what you’ve suggested, but still no luck.

 ![201216-before.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/f/0/df063c7b9b2e66b56c864b3aa8a1c9af63c75b43.png)

I also tried setting the drill widget to visible and the gun to hidden, and visa versa.

I tried consolidating Input Swap and Q, as it seemed like they may have been cancelling each other out.

---

<div class="post-metadata">

**Author:** ![a\_nde](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a\_nde](https://forums.unrealengine.com/u/a_nde)\
**Post date:** [June 24, 2017, 6:41pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/5 "2017-06-24T18:41:14Z")

</div>

Hi Lauterdale,  
on your picture, u set GodDrill or GodGun, but there is no pin going into the visibility-nodes. So nothing happens. I would just use the SetVisibility-nodes like in ur first picture. Get the Widget, then get the Box and then Setvisibility.  
Look at my picture:  
When i click the left mouse button it sets use drill to true and when i release it to false. Then one Widget-Box gets Hidden and the other Visible.  
That should work.

PS U could remove the pin coming from OnRelease, than u have to click twice to use the drill and then the gun.

 ![191191-drill+or+gun.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/8/7/b87f7e34feeb776a87cecacf2cc5afe8fc98fa61.png)

---

<div class="post-metadata">

**Author:** ![Lauterdale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lauterdale](https://forums.unrealengine.com/u/Lauterdale)\
**Post date:** [June 24, 2017, 7:49pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/6 "2017-06-24T19:49:23Z")

</div>

Ahh, I understand. I have it set up like your example, but I’m getting errors.

 ![201228-before2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/b/d/9bd3dbe141bab670e04a98c489782543acb8eef1.png)

Any idea why that would be?  
It looks like it could be that it’s not getting the full path to the gOd Drill and Gun

---

<div class="post-metadata">

**Author:** ![a\_nde](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a\_nde](https://forums.unrealengine.com/u/a_nde)\
**Post date:** [June 24, 2017, 8:04pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/7 "2017-06-24T20:04:58Z")

</div>

yeah probably the reference to ur widget is not working correctly. in whatever Blueprint u put this nodes, u have to have a reference of the widget in which u want to set the visibility. When u use it in ur controller, go to begin play and get a refrence from ur widget.I think u did it right in ur first picture. mine is looking a bit different, cause i just created it fast to show u.

I know its hard to get started, but i would recommend u to go and look at some Tutorials. Look how they did it [here](https://docs.unrealengine.com/latest/INT/Engine/UMG/QuickStart/index.html) for example:

---

<div class="post-metadata">

**Author:** ![Lauterdale](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lauterdale](https://forums.unrealengine.com/u/Lauterdale)\
**Post date:** [June 24, 2017, 8:21pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/8 "2017-06-24T20:21:49Z")

</div>

Alright, thanks for the help! If I have the right setup now, I’ll get started on looking through those tutorials. If I figure it out, I’ll post it as a comment. Until then, you definitely answered my questions. 🙂

---

<div class="post-metadata">

**Author:** ![a\_nde](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@a\_nde](https://forums.unrealengine.com/u/a_nde)\
**Post date:** [June 24, 2017, 8:22pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/9 "2017-06-24T20:22:52Z")

</div>

u are welcome

---

<div class="post-metadata">

**Author:** ![G1K777](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@G1K777](https://forums.unrealengine.com/u/G1K777)\
**Post date:** [August 29, 2018, 7:42pm UTC](https://forums.unrealengine.com/t/toggle-visibility-between-two-umg-images-with-one-key/396461/10 "2018-08-29T19:42:14Z")

</div>

So bad… Why you dont get a reference from your “HandObject\_ref” and then just set the HandObject to Drill\_ref or Gun\_ref. So you would create a ref that he holds something in his hand and then you bind 1 2 3 4 5 etc to the ref so 1 = drill\_ref, 2 = gun\_ref, 3 = sword\_ref and then just set the HandObject\_ref to the weapon you want and done… you could make it inside a function to make it more effective.
