I'm currently creating a game that uses several different timers to increase several numbers, displayed as 3D Text, on the screen simultaneously. When only one number on the screen is present it works perfectly and the number counts up pretty seamlessly. However when more than one number is present and consequently more than one timer is running, the numbers are really glitchy and they all count up showing the same numbers, even though they have different values.
I start the timer using this:
p1Price = Timer.scheduledTimer(timeInterval: 0.2, target: self, selector: #selector(p1PriceCalculator), userInfo: nil, repeats: true)
And use this to change the text:
@objc func p1PriceCalculator() {
var smallHouse1Incremental: Int = Int(arc4random_uniform(UInt32(100)))
smallHousePrice1 = smallHousePrice1 + smallHouse1Incremental
smallHouse1Incremental += Int(arc4random_uniform(UInt32(100)))
if let smallHouse1TextGeometry = smallHouseText1.geometry as? SCNText {
smallHouse1TextGeometry.string = String(smallHousePrice1)
}
}
There are several of this same setup throughout the code, with the only change being the name of the nodes.
Does anyone have knowledge as to why this is happening?
Thanks!