Hello-
I have a turn based game. On the AI's turn, I run a "for loop", which goes through each of the enemy units, and then determines what action that enemy should do (e.g. move, attack, defend). There may be like 100-150 enemies max.
While it's the AI's turn, I am trying to move the Camera2d
around the map (basically using physics_process
to check for arrow key inputs, then updating the the Camera2d
's offset).
The Camera2d movement is sporadic and choppy at best. My guess is that the AI's "for loop" is consuming so much resources that the Camera2d
's physics_process
can't update real-time, and so there is a big lag.
When it's the Human's turn, the Camera2d
's movement works perfectly.
I added a yield(create-timer for like 0.01 seconds) in the AI "for loop", but that didn't help.
Any suggestions on how to limit how much "processing power" the AI gets during their turn?
Open to any ideas, even out of the box...