Change visibility mesh object with button

Hey.

What I want to do is have a button press change the visibility of a mesh object.

I tried this:
Created a Widget Blueprint with one button.
Then I created this blueprint on the mesh I want to show/hide with the following nodes:
d41c13252cd784401863f0a9faf0080d65342d0a.jpeg
Nothing :frowning:

Attempt number two,
3c64affae4dd7fbed50504c10dad9c3b41d8496a.jpeg
Same idea, this time in the Menu BP. Again nothing.

Tried a lot of other things but no luck, hope someone can enlighten me!

Still stuck unfortunately, how do I get a widget button to toggle the visibility of an object?
I tried it with a light, the key press F works, the button still doesnā€™t.
a4326cc61da6e629d39b70a832cbcb4190a58e98.jpeg

Starting to think itā€™s not possible use input from a Widget Blueprint somewhere outside of that blueprintā€¦
Another weekend spend for nothing great !..

You will need to cast to that object, get mesh, then set visibility. That should work. I can make an example or show you an example from something I use later when I get back home.

Thank you, will give that a shot when I get back from work !

Still no luck, I must be missing something but iā€™m doing the same things as the wiki explains.

This is the blueprint of a wall mesh in the level, as a test I just want to print some text on the screen if it detects the button clicked
d03bcbf2568e3c9aaf2b0060d2afe11ec71ddb96.jpeg

This is button graph in the widget blueprint

Nope :frowning:

Just at a glance, you need to make sure to check the box next to ā€œKlikā€ on your Set Klik boolean node after the cast node in your second screenshot. Right now the boolean is getting set to ā€œfalseā€ on click, so even if everything else is set up correctly, the event tick is going to travel down the ā€œFalseā€ half of your branch in the first screenshot.

Thanks will give it a shot later, donā€™t think thats the only issue. When I run the level with logging on I see the ā€œcast to muur_blueprintā€ fail for some reason.

It will fail, you have no reference of an object going into the castā€¦

What are you trying to achieve? Looking at something, clicking and making it disappear? If so you could raytrace to it and on the hit output is equal to what you want, going into a branch which then casts to the class that has the kik thing in, set to true (ticked).

I want a button (from the widget blueprint) to toggle the visibility of an object.

The reference part I donā€™t really get , Iā€™ve tried to create a var. from a scene object and wired that into the Cast To Object slot but no luck so far.
What is confusing to me is why it needs a reference in the first place. The blueprint I cast to is from a mesh object already.

6.JPG

Add a var with the blueprint iā€™m casting to
7.JPG
nope :frowning:

Hi Cultor,
I have the same problem ā€œChange visibility mesh object with Widget buttonā€ 14 days and still nothing , I do not understand it :frowning: If you come up with something, I would be really helpful.

Hello,
Instead of a reference, which need to be set with the specific actor in the level you want to interact with. (On event begin play for example), do a ā€œget all actorsā€ selecting your blueprint in ā€œactor classā€. If you have only one actor of this class, drag a ā€œgetā€ from it and drag your bool from it (donā€™t forget to check your bool) If you have more than one actor, you will need to use a tag to know which actor activate : https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html

I double post to show you the 2 possibilities :
1 in level blueprint : You create your widget and you immediatly ā€œsetā€ your reference with the blueprint ( selected in level and right click to have it in level blueprint) then in widget, you use the reference filld and drag your mesh (cube in my example) to set its visibility. (i used a custom event named ā€œevent clickā€ but this is the click button event as the one under)

2 in widget only : You get all actors of this type of blueprint and get it (because there is only one. if there was more, i would have do a for each loop and cehck the one i want to use)

In order for any blueprint (other than the currently possessed pawn) to receive input, you must first turn that on:

Without this, no input events or functions (for example: on button press) will work.

I think this might be your problem.

Thanks a lot Fen, managed to get your second method to work! Will give the first one a go tomorrow which seems a bit more complicated.
Not quite sure Iā€™m completely understanding why it works without all the casting / direct communication but itā€™s great to see something happen now :slight_smile:

@DSursely
Thanks for the tip will look into that. The only place Iā€™m using the Get Player Controller now is in the level blueprint to enable the mouse to click the button
38825f1b4e9e3f6e859b94babf32624ddcd8f095.jpeg

Happy that helped you ^^ If you need more explanations, donā€™t hesitate to come back asking.

@ DSursely : Button is in a widget, not a blueprint set in level. But you are true that if it was a blueprint in level it would be needed.

Hi Fen ,
Thank you very much, second method works for me.
My problem was : 1. Get all actorsā€¦box 2. minimal blueprint on static mesh -for show in list/