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
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 !
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
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.
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.
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!
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.