As the title says I am looking to make an efficient currency system. I have a variable in a blueprint HudInfo called currency. Within the world the the player is able to spawn actors that add to the currency over and over on a timer.
The player is required to pay for those actors through a menu blueprint that subtracts from the variable currency. I have not found anything in this answer hub that really addresses this question. I am able to do this with one blueprint but not multiple. Any suggestions for an efficient system to do this would be greatly appreciated.
Well, to start with, you really want to consider where you’re storing information and logic. For instance, the currency information, should it be in the HUD? Or should it be in a class for keeping track of player state?
The currency generators you describe - they all have commonality with each other in access, correct? So you’d want a blueprint interface on them - for example, GetCost could be a method on each of these blueprints. Then, you could keep them in an array, and when someone wants to buy one, you call GetCost, which gives you how much the generator costs. Then you can decrement that amount from currency or return an error that there isn’t enough.
Make sense?