Problem with data handling and two more questions.

Good afternoon.

I’m new to unreal and I’ve been in my head with an internship project for a long time and I’ve been stuck on this problem for at least a year, that’s why I turn to the forum, which I’m sure will be of great help. I expose you my problem and two questions, in case you can advise me.

I would like to have a system in Unreal in which, it is a resource management, in which I want that each element of a list, for example, a list of mines (mines of metal, wood, food, etc.) and in which, each one, has its own characteristics, that is to say, it would be a list inside another list, with for example, its name (to show it later in screen), maximum capacity of storage, that each one stores its sprite to assign it, etc.

All these characteristics, I would like to access it individually in case I have to access any of its data to modify it.

I want that the list of the mines, goes through them and each second, generates the corresponding resource that is assigned to it, that is to say, each second, it will generate the resources of each mine, and each mine, will generate resources faster than another, for example, the wood mine, will give more resources than the metal one, because it is more complicated to obtain (I do not believe that it is very complicated, simply each second, each one will have a float, that will be the greater or less according to the amount that is assigned to it). What would be a list of mines and inside each mine, another list of its characteristics, but it would go through the list of mines and according to the characteristic of each one, it would generate more or less resources.

What I discovered is that the best way to do it is with a map collector (or so I think).

Also I want that these resources are always represented on the screen every second, when these resources are generated.

The other questions are:

  • I would like to learn more about this topic, but I do not know what information to look for or tutorials, I have followed some of unreal, but do not see any of this type of problems, to practice, if you can recommend me something, to help me improve in this field, I would appreciate it, because I did a BP course, but it did not help me much.

  • I also wanted to ask you, how do I know when I have to use BP or code in C++.

Thank you very much in advance and best regards.

You will need to research on these potential solution:

  • Data Table (just as the name keep record of data) but is readonly ingame, so you can’t modify data ingame so to compensate you can use array variable as an example for the Quantity which is a variable that will require change overtime ingame.

  • To save/load data, you will need game instance + save game (check on yt)

  • Might look for Data Asset as well (but am not well experience on this one so i can’t tell)

  • For the generate every second, look for Function Timer

I recommend to get familier with BP first and then consider c++ for perf of looping data.

Good ones.

Ok I will look into them.

I researched as you say, the solution I saw was a collection with maps, as it let me make a list inside another list, but I would like to have control of both of them and the characteristics of them.

Thanks for the contribution, could you tell me some tutorial of unreal or some recommended video to facilitate me with the blueprint? I’m mainly looking for practical things, because I’ve studied theory but it hasn’t helped me much. I’m also interested in data related to practice it.

Best regards.

Core features, i recommend: Begin Play | Blueprints | Tutorial
And all the BeginPlay from here: BeginPlay | Learning path

For specific things, you will need to go on youtube.

Thank you very much for your contribution, I’m reviewing it and it’s helping me improve, but it still leaves me with doubts about how to do it in the best way, and above all, to make it work, the method that I’ve outlined in the post, since I don’t see how I could recreate it and how it would be done, as I find it somewhat complex.

As I mentioned before, I’ve done a lot of research and tried to gather various information on the topic, but I’ve never found anything similar that I could use. I even downloaded the new tutorial on resource management in Unreal Engine, which is similar to Age of Empires, although it’s not exactly what I want to do, but I can’t figure out how they have it configured to make it work. I think I need to be at a more advanced level of understanding to learn about that project.

Thank you for the contribution you’ve been able to provide so far because it’s helping me a lot. If you could provide any ideas or suggestions on how the code could be, it would be great.

Thank you very much.

Glad i could help :hugs:

There a free project on the marketplace, it an RTS project “CropoutSampleProject” if you want to check out.

I explained a bit on Save here: Can you check if ANY save file exists?

Take your time learning, just make sure to avoid for loop and make use of soft reference if needed for data handling to preserve memory.
And function interface to properly communicate data betw actors.

1 Like

Do you think interfaces are better than event dispatchers? In this post here Why use event dispatchers vs interface when ED's need a hard reference? they argue that interfaces can be very slow and that you should use EDs whenever possible instead.

Whether it slow or not, i will have to test these one day :innocent:.

What i can tell, you will run on specific situation where you will know naturally what to use.

Let say you are making an Interaction System and using BeginOverlap event to interact with a NPC to get it name, here we can only use function interface because we don’t know the class exactly but can get the job done with the Actor output pin, and we can’t use event dispatcher here (for the target to call the function).

Now let say you are creating a dialogue main widget bp with a vertical box, the vertical box is where will be your Choice Buttons. The button of course will have to be dynamic depending on the number of choice provided.

So we create another widget bp that just contain a button choice. Now inside this widget bp, the button OnClicked will have to call something, i can’t really use an Interface here since i have no clue what the target could be.

So i prefer to just use event dispatcher, that way when am creating lot of child button inside my main widget, i just do an easy bind event on these onclicked. I can also unbind/rebind these button which can be handy.

1 Like

Thank you very much for your contributions.

Yes, exactly, it is the project I was looking at, but as I said, it is an advanced code to find out exactly how it works.

Therefore I would like to see, if someone could give me an example of what I exposed in my first post, because I see a complex code and I would like to see how more advanced people raise it.

Thank you very much to all! :slight_smile: