Help: I may have an issue. Can you assign "On Click" to a spawned 3D Widget?

Hi

I know how to do it when the Widget is part of the blueprint, but I am spawning 3D Widgets that I would like to have an on click event.

I have the same widget spawning 5 times, with different data. Excuse the bad video (Computer upgrade soon :cool:)

Regards

So I have been able to turn “ON Click” on, but having trouble referencing it to each widget. It either pulls 5 or 0

Capture.JPG

I am just curious,

Since I only have 10-20 widgets per blueprint.

Could I reference I reference the World location for click, if possible, how would I reference that back to the one BP

So if I have one widget the is 100/100/0 in one BP and another at 2540/2654/0 in another BP, could I easily reference that?

hey there,

why dont you just add the OnClicked in the Widgets Blueprint?

Thank you for the reply

But I am using the same widget over 100-200 times in the game and each has a different reference.

Each BP has up to 20.

So I need to reference each widget as they will have a difference result.

i dont see your problem here.

add OnClick in widget blueprint and call f.e. a dispatcher event and give the widgets reference as param.

Then assign the dispatcher to your character for example and read the values from the incomming widget

Hi

I suppose the issue is that the way I am doing it does not work.

Can you help with the reference, as I am lost.

I have tried and got no where, or need to make the widget as parts of my components TAB (which I a lot more work).

Any help would be great.

Hello,
No idea about widget solution as i have no more used umg since long but as work around, to find a better solution, i would set a box around widget (with widget as parent of box to have both moving or opposite) and use it for on clicked event.

Hi

Thanks for your reply, but same issue in my head . How do you reference a Randomly spawned trigger box.

I had this problem. I solved it the same way I solved the reinst issue.

I made a button and gave it a few variables. A string called “instructions,” a text for the button text, a texture 2d for the image, etc. On click, it sends an interface message to another passing “instructions.” That has a switch on string and depending on what the instructions are it carries out the button’s intended behaviour. Does that make sense? I’m not sure if I’ve explained that well enough, haha.

This way you can spawn a new button and give it its instructions on spawn.

hmmm, the answers of the other 2 guys here confusing me.

Am i right that you want the following:

  • During gameplay you spawn 3D Widgets when they should
  • each Widget will have different data stored
  • each widget has an OnClickEvent (set up in widgets blueprint)
  • when you(Controller/Character) click it you want to get the data of that widget

The problem is how does the receiver (you) get the information because you does not have any reference to that widget?
For kind of these purposes are Interfaces made. So when you click on that Widget it will do an Interface Call, after the OnClick event, and give the desired information of that blueprint as input parameters.

The Interface you have set up now then routes the information to the receiver which will handle those then.

If thats your problem and you dont know how to use interfaces i can show you.

If thats NOT your problem then sorry for disturbance :smiley:

Hi

I appreciate the answers.

Wall

  • each widget has an OnClickEvent (set up in widgets blueprint)
  • when you(Controller/Character) click it you want to get the data of that widget

There is not data or bindings in the widget. If you look at the top video, the data shown on the widget is produced it the building as such.

That is me issue, I can reference each widget on spawn, then I loose them to the gods. :frowning:

Interfaces, Not really ever used them, so need help with that too :slight_smile:

This is how I spawn.

I have had a little luck thanks to Mr Newton.

I can now find the on click. Well I can find every on click. :slight_smile:

But referencing it. Any ideas on how I can Find the data.

I am playing around “Casting” and hope to pull a variable which then I can compare and run a query.

At least : On spawn, you can add it to an array “RefArray” and set an int “Ref” with index value in spawned bp. Then you can “get” it from array with the right index.

Hi

Could you show me a basic setup. Brain not working today.

Based on initial blueprint : In spawned bp : an integer “Index” editable. In Level BP or where spawned is done : An array “SpawnedWidgets” with “Bp_Widget” as variable type and :

Edit : If you set your logic in bp, you may not need any reference to this bp.

Thank you for replying .

I got lost here : In spawned bp : an integer “Index” editable

So in my 3D widget, I make a Integer/editable, but how to do index?

And me again :slight_smile:

An array “SpawnedWidgets” with “Bp_Widget” as variable type and :

What type of Variable should they be?

Told you brain was not working.

In your bp : index is the name of the integer variable.
In level bp : spawned bp variable type (selected in details) is the bp you spawn, your bp widget.

Cheers

With your Add and Find, which array are you using for that?

And is the “Set” after Add and Find, For the Index, what type are Node is that? Can not seem to find it.

This is what I have so far.