Topic was automatically imported from the old Question2Answer platform.
Asked By
dimdev4
I need to iterate 100k+ size of arrays without blocking/freezing the app, or sometimes some pathfinding algos that could take some time but I want to do all of them in the background. Is that possible? Using threads seem doesn’t work on me (still freezing) or did I do something wrong?
You could use a timer and do a small amount on each event?
var test:Array = [1,2, 3, 4, 5, 6, 7, 8, 9, 10]
var index:int = 0
func _physics_process(delta: float) -> void:
if index < test.size():
test[index] *= 2
index += 1
else:
set_physics_process(false)
print(test)
Any idea to make it in a “function” format? So let’s say I have these 2 functions that needs to be run in the background.
func a() -> int: pass # the time consuming function
func b() -> int: pass # the time consuming function
And I want to be able to call it as needed, without blocking other activities.
dimdev4 | 2023-01-25 17:01
I would have to know what the functions do to help with that.
If the functions can be broken down into iterations then it is possible to use the method I gave.
If the functions must run and complete without interruption then you are definitely going to have to use threading. And I have no knowledge of threading in Godot.