Godot Version
4.6.2
Question
hallucinationTimer += delta
for i in currentHallucinations:
var T = 0
for ii in i.boltArray:
if ii != 0:
if fmod(hallucinationTimer, 1.0 / ii) >= 1.0 / ii - delta:
spawnBolt(10 ** T, i.position)
T += 1
The above code block is my code for not only a custom timer, but also triggering a function to spawn an instance of a “bolt” whenever the timer hits certain values that correspond to an array telling this code how many times per second it should spawn a bolt.
The code works; there’s technically no problems with it, but the variable T is ugly implementation, and I can’t use find because of the fact that values can be the same (for example, three 1’s in a row) and it’ll just grab the furthest down value.
Does anyone have a better way of going about this? Or is this actually good implementation?