How can I make Actor appear and disappear using a UMG button
I've tried to set it up so that when you press a UMG button on screen, an actor will appear or disappear. I got the button appearing but i realized you can't reference an actor unless it's in the world blueprints. How would I make it so I can reference an actor in the button's blueprint?
asked Mar 04 '15 at 12:37 PM in Blueprint Scripting
The issue is not how to reference one but rather how to get the correct actor and this really depends on your use case.
Do you just have one type of actor of which all should disappear when clicking this button? Or just in a radius around your character? Well in this case you can do a "Get All Actors from Class" which will present you an array. For the distance check well just do a for each loop and check the distance between your character and the actor location and look if it's within the range and if so hide / remove it.
Should only one specific actor disappear? Well you can just create a variable in your character which you access from UMG. If it's valid you enable the button and if not (so there's nothing to point to) it's being disabled. When you click it you hide it. Like that you can reference the actor once your character overlaps with some trigger volume which also allows you to reference different actors once you are at different positions without any additional work.
If you have a different usecase or need a bit more explanation on how to set this up just comment with your exact usecase or issue ;)
answered Mar 04 '15 at 12:45 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here