Spawn static mesh by UMG button

Hey lobaanicht-

You can set an OnClicked event for the button that, when pressed, calls the SpawnAcotrFromClass node to spawn an actor from the appropriate class.


hi there!
i want to create a button in my widget, to destroy and spawn a cube static mesh. (example name “CubeA”)
i want to make this with a checkbox. the checked button destroy the CubeA, and when the user unchecked it, it spawns.

the first part is allready done. the cheked button destroy the CubeA. but how can i spawn it back?

hi ,
thanks for your answer! unreal engine is new for me. can you explain your answer a little more?
when i use spawn actor from class, no static mesh appear. there must also be a function to set the location of the object.

When using Spawn Actor from class it will prompt you to choose which class to spawn an actor of. So the simplest solution would be to create an actor blueprint and give it a static mesh component set to the static mesh you want to spawn. Then in the SpawnActor node you would set the Class field to the blueprint. For the location you can pull off of the Spawn Transform pin of the spawn node and choose Make Transform. This will allow you to set the location, rotation, and scale of the actor when it is spawned.