I'm making a 2D sandbox tycoon in UE4. I haven't started the money system yet, but I was wondering how I could make a money system that gives you a certain amount of money per real-life minute. Then, I want to connect this system up to some text so that the digits go up by whatever amount each minute.
If you only want to do this while the game is running you can use the timers the engine provides.
Brief summary (Current UE Version 4.22):
Create a method which should be called after the timer ends (e.g. rewardCallback)
Add a Blueprint node called 'Set Timer by Function Name'
Set the function name in the blueprint node to be the name of the method created in the first step (i.e. rewardCallback)
Adjust the other parameters to your needs
Make sure the node gets called at least once (or more often if you don't loop the execution of it)
If you want to extend it such that offline time also gets taken into account then you might want to simulate the time the player was away.
E.g. In an extremely simple case:
Delta_away = time_now - last_logoff_time //in minutes since 1970 Reward_away = reward_per_minute * Delta_away
Unreal offers several built in timers and, depending on your needs, I'd suggest either GetTimeSeconds and GetRealTimeSeconds. Both do the same job but GetTimeSeconds gets paused when the game is paused whereas GetRealTimeSeconds does not.
You'll need to set up two more variables. One to compare the time since money was last added (reset every 60 seconds or however often you want more money added) and a value for the total money.
HUD's are hard to explain in writing so I'd suggest finding a YouTube (or similar) video but essentially, create a HUD Blueprint (found in Add Blueprint->User Interface->Widget Blueprint) and add a Text (or Text Block) to your creation. In the details tab, where you enter what text you want, you'll see a button labelled "Bind". Click this and select "Create Binding".
Inside the binding, you now need to CAST to wherever you set the money variable and hook the output node up to the money variable. Unreal should convert it to Text automatically but you might need to do this yourself.