![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | jitterbeetle |
Since we run in a loop at 60Hz, or 60FPS if you like, how do I do something at 1 second intervals?
(don’t know how to format code here)
var globalsleep = 1.0 - (1/60)
var prevdelta = 0.0
func _ready():
# get ready now
func _process(delta)
prevdelta += delta
if prevdelta >= globalsleep:
print("prevdelta = ",prevdelta)
prevdelta = 0.0
But there is always some time lost and prevdelta will be more than 1 second.
But that is strange because if I run and just print(" delta = ", delta) I see 1/60 or 0.0167
Something seems broken to me. I am using git master.
I hope someone can try to explain this but I think it’s a bug. Or is there some kind
of global lock like python GIL? Which would mean that Godot is all in a single-thread.
Or am I misunderstanding some signficant design behavior?
Might not be what you’re looking for, but you maybe could use a timer node set to 1 second. Not sure if that is more precise.
Diet Estus | 2018-05-16 14:13
I will look at that but unless it uses some other mechanism the timer node would be coupled to the same timing mechanism and suffer the same symptoms.
There were some timing related commits recently so I need to pull, rebuild and retry.
jitterbeetle | 2018-05-16 15:46