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:
Nothing
Attempt number two,
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.
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.
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.
Hi Cultor,
I have the same problem “Change visibility mesh object with Widget button” 14 days and still nothing , I do not understand it 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)
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
@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
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/