Part of my game has cities generating resources every few seconds: wheat and gold.
Here’s how it works (screenshots at the end for reference):
Every 1 second, each
cityResourcesStored.wheatvariable gets added to by the
cityResourcesOutput.wheattotal. In this example, it’s 10 every second
When I click on the
City Viewlayer appears, and along with the
locationobject name as a text object, there are
Gold: Xtext objects with the current
cityResourcesStored.wheat(and one for gold) values. This works fine, and the ‘stored’ variables update and display correctly.
When I click the Collect button on the
City View, the ‘stored’ variables are added to the player’s
player_resources.wheatglobal variable (same for gold), then set to 0
The ‘stored’ text objects should then show 0
The issue: The ‘stored’ variables are reset to 0 correctly (I checked the Debugger), but the ‘stored’ text objects are flashing and going back to the pre-collect number, and keep going up.
The weird thing is, the first instance of the
location object is resetting to 0 with no issues, but any other object instances aren’t resetting.
I’ve got a
selected_location global variable, and any actions need to pass the “is this object the
I’ve attached screenshots of my events and the game UI below, any help would be appreciated!
(Please ignore the awful UI, they’re all placeholder assets so I can focus on development)
This is the events list
This is the first instance of the
City Window, after clicking the shopping cart icon (the Collect function). It reset to 0 without any issues.
This is another instance of the
location object, and you can see it’s got to 460. I couldn’t get a screenshot of the 460 → 0 → 460 flashing, but hopefully you’ll get the gist!
Edit: realised I named the
location objects as
city by accident