How do I get a UI button to activate an event in the scene? Say click a UI button and have that start a day/night cycle?
Create a widget, add a button and trigger from the On Click Event.
Recommend watch the whole video, but the first 5 minutes can help you:
To make it show to you inside the game window, follow this.
I’ve watched several of those videos and am still coming up blank. That one did point me to the event dispatchers. I have my button show up in my window. For the sake of simplicity, I want to click that button and destroy a cube in my scene. I set an OnClicked event in my HUD. My thought it was as simple as connect that to an event dispatcher call “DestroyCube.” From tutorials, I thought I should be able to go to my level blueprint and place a node from that event dispatcher, then link that to a destroy actor and the cube. But that DestroyCube doesn’t appear in my level blueprint.
The DestroyCube is actually placed inside your Level? You should get its reference just by selecting it, opening the level BP, right click, create a reference to…
I can refernence the cube that is to be destroyed in the scene, but i can’t reference my event dispatcher “Destroy Cube” in my level blueprint.
You are right, my mistake. Level blueprint is not recommended to handle these kind of events, I suggest you create a GameState, so in the begin play, get the Cube`s ref using Get All actors of class (StaticMeshActor). Create a function/event inside GameState to destroy the cube.
Inside the widget(HUD), get the game mode, cast to yours and call the function you`ve just created after the OnClickEvent. Thus, you will have access to this event.
This is not the best approach to get the references you need, since I dont know details about your game, but be aware Get All Actors of Class is expensive and you should probably create specific actors(to filter only the cube) or use Blueprint Interface is some cases.
Oh, well I would prefer to take the best approach. This is the first time I’ve tried using buttons and am trying to learn the process. In the end, I want to be able to use it mostly for architectural visualization. Something like this: UE4Arch.com - Villa Savoye - YouTube. I want to be able to click buttons in the UI that will trigger stuff like time of day, or other animations or triggers in the scene.