[novice question] A spawn actor with widget attached to make it rotate, why it doesn't work ?

Hi,
i am new here, this is my first post. I hope someone can help me.
I made a search with no success about this problem.
I created a system where a cube spawn in the world from drag&drop operation from an inventory
widget (situated on the side of the screen like an hotbar).
this cube is an actor that has a static mesh and a widget
In game once you click on the cube the widget appear and it has three buttons:
1 to turn the cube 2 to destroy it 3 to make the widget disappear again


in the blueprint i made a link of a custom event that start from the widget (road is the name of
the cube static mesh)

and it works
BUT if i create another cube and click on the widget to make it rotate it makes rotate the
first cube i created before. The same if i click on destroy.

what i should i know to make it work ?

What’s the widget blueprint look like?

Just a tip… widgets have no clue what actors or components they are in. You have to set in in the begin play event (or manually).

Hello there @KhaosAvoid!

When possible, you could provide a bit more information about your blueprint/widget logic and how they interact with each other? This will help me get a better idea as to what may be going on in your code.

Still, I would like to take a stab at helping you fix what may be going on here. But from what you provided so far, it sounds like you code is working as it should, it’s just that whenever you click on your widget to move or destroy the box, that this action is still being done on the original box which you have made. There could be a few reasons for this.

  • The first line of defense for this sort of thing is to just try to duplicate the box blueprint that you currently have. You can do this by selecting it and pressing ctrl + d.
  • But I am assuming that this has something more to do with how you are casting to your box(let me know if you are using a cast to access data about your box).

If this is the case, it is important to tell Unreal which box that you want to cast to. For your case, the simplest way of doing this would be to shoot a line trace out of your character to the box that you would like to affect and use the reference of the box (which the line trace hit) to inform your widget blueprint about which box the action should be made towards (for destroying, moving, etc.).

If you need some advice about how to get any of this sort of stuff to work or you don’t understand, I would be happy to explain :slight_smile:

i have read your answer and i am trying to figure it out by myself,
but

i will try to give you more details

in the actor (trackdefault) that has a static mesh cube and a widget attached
i made simple this custom event to make it rotate it

in the widget (separated blueprint - ui) i made this

both are in the hierarchy of the editor (they are not placed in the map)

simulating the game session:
every time a player place a cube
when click on that cube a popup widget minimenu comes out : turn, destroy or cancel options are in it
when you click on ‘turn’ the cube should turn 45*
then you place another cube and click on it, again the little widget comes out.
you click on it ‘‘turn’’ but it turns the first cube you placed and not that last one.

i feel there is something important of how the engine works that i didn’t understand here…

i feel there is something important of how the engine works that i didn’t understand here…

Read the toolip of this node. It gets it you the first actor it can find, not the widget owner. Best think of it as of a Random Actor.


The behaviour you’re after is best done with dispatchers.

There’s no script in the widget. If you do not want to use a button, add a custom dispatcher and bind to that.


1 to turn the cube 2 to destroy it 3 to make the widget disappear again

A custom Dispatcher with an Enumerator would work best here. All of this can be handled by a single event.

so i must go to edit in the blueprint space of the widget attached in the actor… and not
in the UI separated widget ?
here:


and not here:

in that case, i cannot have three different buttons i guess… but only one, right ?

anyways… thanks a lot for your time and the quick answer.

  • create a new enumerator in the Content Browser:

  • in the widget:

create a new Event Dispatcher, add the enumerator as parameter, have the buttons call it.

  • in the actor, bind to the custom dispatcher:


1 Like

this is amazing, thank you for the precious help.

i will try to implement your solution soon.

anyway, i need to learn more and more… there is so many things that i don’t know yet.

1 Like

OMG it works.

thank you so much… i am speechless.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.