Spawn an Actor using a widget button

I create a variable and then on the variable type I find and select the Piece and the Target

Hello. I want to spawn an actor using a widget button. I have found a document that let’s you spawn actors by pushing a specific key (done on level blueprint) but what I need is to spawn an actor on a target by pressing a widget button. I tried to Implement what I did on the level blueprint to a widget I created but nothing happens

I also need that Actor to be invisible before I click the button because currently It is already visible and placed inside the game when I press play. Thank you in advance

You are probably not defining the class to spawn. How are you setting the reference for the piece and target variable?

Here is a very quick Tutorial:

in Your Widget BluePrint

  • add “get all Actors with tag” , on tag name enter “SpawnHere”
  • make a “for each Loop” out of “get all actors” node
  • “get location” of forEachLoop’s “Array Element”
  • add a “Spawn actor” node and connect it to “ForEachLoop”
  • connect “get actor Location” to “Spawn Transform”

in your Level:

  • add a “Target Point” actor
  • search for word “tag” in in target point properties, Actor Tag will show up
  • add a new tag and enter “SpawnHere”

now when you run the game, as soon as you pres the button in your widget a new actor will spawn at the location of this target point. you can copy this target point to multiple location and it will spawn a new actor in each of those locations.

2 Likes

Whats the point of exec loop ?

hello, I used this to spawn an actor with a UMG widget, The issue i’m having is that the Widget actor is no longer able to follow the rotation of another actor I want this one to spawn in and act as a child to the rotating actor but it does not update to location making the alinement wrong.

This was really helpfull!!! Thank you!