[Need Help] Tycoon game shop : Set structure member in another structure

Hello everyone, I work on a tycoon game where I try to do a shop where you can buy machine that have data like
the name of the machine
the money that it generate
the speed of the generation
and the price of each upgrades

to do that I used 2 structures : one with the stats that a machine can have

and one with each machine and the stats they have with the previous structure

I also have a shop with a first BP of an shop that is on my map and a second one that is an ui of the shop, in the ui i have buttons where you can buy a machine and it spawn it at a location, and another buttons where you can upgrade the stats of the machine like the money that it generate and the speed at which it generates it

the problem is : when I buy a machine and i upgrade for exemple the money it generate, the money increase in the structure of the shop ui but not in the structure of the machine that I spawned when I buy it, and when I close the shop and I go back in the structure came back to the default stats I set.

I wish I explain my problem correctly and clearly and I wish you guys can help me thanks !

My bet is that it’s due to the way you update the struct. Blueprints copy a lot of data. Oftentimes you end up working with a copy.


  • this is OK, it’s a ref - note the diamond icon shape:

The change will propagate back to the var, we are setting by reference.


  • this is not OK:

The loop made a copy, the original variable will not be affected. To make it work, you’d need to:


At least Get is nice because it gives you an option:

The top one will not work.


Nested structs are somewhat evil:

Arrays of nested arrays of nested arrays of structs are even worse.


When you pass struct to a function, you can pass by-ref:

If you pass a copy, the function will operate on said copy.

Hi ! thanks you for your response it gives me a better sense of the structures.

I check my blueprints following your message and i did not understand why the stats doesn’t change cause as you can see on the screen the structure is a reference in the set member blueprint

despite it is a variable do the S_items is an ref ? and if it is why do the stats came back to the normal when i close and reopened the shop ?

How is this done?

i create the widget if it is not already created and with a flip flop node i
A : add to viewport
B : Remove from parent

I still need help if someone pass by :cry:

Can you show how this is done, I feel you destroy a widget and create a new one each time. For example:

This :point_up: will never work. This :point_down: could, though:


If that’s not it, you may need to explain this bit in great detail:

when I buy a machine and i upgrade for exemple the money it generate, the money increase in the structure of the shop ui but not in the structure of the machine that I spawned when I buy it, and when I close the shop and I go back in the structure came back to the default stats I set.

Especially this:

the money increase in the structure of the shop ui but not in the structure of the machine that I spawned when I buy it,

Could you demonstrate how this struct’s data is moved from one actor to the other.

since earlier i try to better think about my problem and i learnt more about the “instances” when i create something like the widgets or when i spawn an actor and you are totaly right i create a new widget every time

how did you do the node where you get the variable and look if it’s valid ?

That being said I found a solution to my first problem, and you give me another solution thanks you i’m glad !

I would also like to know how to refresh the stats of an “instance” or a “child” since when I spawn an actor it keeps the stats of my structure but does not refresh them when I change the values ​​of the structure.

Thanks you a lot again !

First you Get the var as usual, and then right click it to convert to Validated. It does the same as checking it with isValid but with fewer nodea. Handy.

Not sure I follow and what you mean by refresh. When you instantiate an object, it gets a new struct. You can then manipulate the data in that struct.

Perhaps it’s an issue with trying to manipulate a struct copy rather than doing it by reference - see my previous posts above. Or post an example.

I i have done a image that is supposed to explain all my problem a lot clearer, hope it will be !

here is the PSD cause i check the image and we can’t see anything

explainations.psd (16.5 MB)

Hey there, I’m reaching out to share an update on my progress and the solutions I’ve employed to make my store function and enhance my machinery in my tycoon game! In fact, I’ve finally managed to figure things out with the structures. I have three important blueprint components: one for the machine, one for the shop, and the UI of the shop that opens when I click on it. Essentially, I created a button that, when clicked, triggers a custom event within the shop’s blueprint.
like this :

This custom event then calls the reference to the machine’s blueprint and takes the reference of the structure. I then use ‘Set Member in Struct’ to modify the variables as I want, and there you have it!

And the machine Blueprint here :

and it work ! look at that :

also @Everynone thank you for trying to help me, but I was explaining myself poorly, between being a beginner and the language barrier, even though I speak a little English. God bless you.